CLOSE ALL
CLEAR ALL
CLEAR

SET PROCEDURE TO qdfoxJSON
JSONStart()

?"JSON Test #3"
?"Version " + JSON.Version
?
?"THIS TEST SHOWS HOW TO USE ENCODE AND DECODE VFP OBJECTS USING JSON HELPER"
?
?"Creating test object..." 

LOCAL o
o = CREATEOBJECT("Person")
o.firstName = "Victor"
o.lastName = "Espina"
o.Age = 42
o.DOB = {^1970/11/18}

??"Done!"

?"Serializing object..."
LOCAL cJSON
cJSON = JSON.Encode(o)
?cJSON

?
?"Deserializing object..."
RELEASE o
o = JSON.Parse(cJSON)
?"Name"
?"",o.firstName, o.lastName
?"Age"
?"",o.Age
?"DOB"
?"",o.dob
?"Class"
?"",o.Class
 
?
?"Test completed"
?
?"For more information, read initial comments at qdfoxJSON.PRG file"

RETURN


DEFINE CLASS Person AS Custom
 FirstName = ""
 LastName = ""
 Age = 0
 DOB = {}
ENDDEFINE