Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert json to cursor
Message
De
31/10/2019 11:00:18
 
 
À
31/10/2019 09:08:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
01671750
Message ID:
01671763
Vues:
77
>Hi!
>
>>https://github.com/VFPX/nfJson
>
>Thank you. Its beta nfOpenJson function seems work but date columns are not parsed.
>Also it contains private all command which causes my application stop working.
>
>>https://github.com/sait/vfpjson
>
>It does not contain json to cursor method.
>
>Andrus.
>
>>I never used these myself, so I can not say if they will work :-)

Hello Andrus, nfOpenJson works, but it is deprecated.

As Dragan says, just use nfJsonRead -it will get you a vfp object wich array of objects you can iterate:
TEXT TO myjson noshow 
{
    "status": "OK", "statusCode": 200, "messages": null,
    "data": [{
        "payment_type": "banktransfer", "fine": "0.200000", "quote_id": null, "order_id": null, "prepayment_id": null, "credited_invoices": [],
        "interested_party_address_id": 279, "project_id": 875, "currency": "EUR", "owner_id": 3, "date": "2019-03-15", "deadline": "2019-03-20"
    },
    {
        "payment_type": "banktransfer", "fine": "0.30000", "quote_id": null, "order_id": null, "prepayment_id": null, "credited_invoices": [],
        "interested_party_address_id": 79, "project_id": 85, "currency": "EUR", "owner_id": 3, "date": "2019-04-15", "deadline": "2019-43-20"
    }]
}
ENDTEXT


    
oJson = nfJsonread(m.myjson)
    
create cursor myCursor ( payment_Type v(20), fine v(20), date c(10) )


for each oRow in oJson.data
  insert into myCursor from name oRow
endfor

browse
Check this thread to find some techniques I shared to work with complex objects:

https://www.tek-tips.com/viewthread.cfm?qid=1796615

From nfJson Documentation: "automatic cast for datetime properties ( ISO-8601 basic format & vfp compilant as described on https://en.wikipedia.org/wiki/ISO_8601#Times. )"

PS:
Can you tell how "private all" crashes your system?
@nfoxdev
github.com/nfoxdev
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform