Web Connection
JSON 2 VFP
Gravatar is a globally recognized avatar based on your email address. JSON 2 VFP
  Vincent H.
  All
  Nov 15, 2021 @ 06:05am

Hi Rick,

What is the best way to turn a JSON file into a VFP cursor ?

Thank you in advance

Gravatar is a globally recognized avatar based on your email address. re: JSON 2 VFP
  Vincent H.
  Tore Bleken
  Nov 15, 2021 @ 07:25am

OK, thanks. I read it ...

Gravatar is a globally recognized avatar based on your email address. re: JSON 2 VFP
  Vincent H.
  Rick Strahl
  Nov 16, 2021 @ 12:16am

Thanks Rick,

But I get: Property LOCOLLECTION is not found

Here is my code:

loSer = CREATEOBJECT("wwJsonSerializer")
loCusts = loSer.DeserializeJson(FILETOSTR(GETFILE()))
CREATE CURSOR CTest (Nom C(200), Crcpen C(6))
? collectionToCursor(loCusts, "CTest")
Gravatar is a globally recognized avatar based on your email address. re: JSON 2 VFP
  Rick Strahl
  Vincent H.
  Nov 16, 2021 @ 11:09am

Not sure this works for me:

DO wwJsonSerializer

SELECT * FROM customers INTO CURSOR TQuery

loSer = CREATEOBJECT("wwJsonSerializer")
lcJson = loSer.Serialize("cursor:TQuery",.t.)

*** Create empty cursor
SELECT FirstName, LastName, Company, BillRate FROM Customers ;
    WHERE .F. ;
    INTO CURSOR TCustomers READWRITE
    
*** Manual Cursor Deserialzation    
loCustomers = loSer.Deserialize(lcJson)   && collection
CollectionToCursor(loCustomers, "TCustomers")    

*** Or built-in Deserialization 
* loSer.DeserializeCursor(lcJson,"TCustomers")


BROWSE nowait
© 1996-2021