I need to create a json string to send to my server. I have several structures and structured arrays.
I am however not sure how to use the INSERT functions like InsertJSONStructure and InsertJSONArray
I would expecty below code to produce something like
{
"Profile":{"naam":"aaa","straat":"bbb","gemeente":"ccc"},
"Client":{"naam":"ddd","straat":"eee","gemeente":"fff"},
"Licence":[
{"id":"person aaa","transactionid":"TR_1","serial":"ABC"},
{"id":"person bbb","transactionid":"TR_2","serial":"DEF"},
{"id":"person ccc","transactionid":"TR_3","serial":"GHI"}
]
}
but i always ends up with only the last structure in the composed json
{"naam":"ddd","straat":"eee","gemeente":"fff"}
What am I doing wrong here ?
Code: Select all
Structure AdresStruct
naam.s
straat.s
gemeente.s
EndStructure
Structure LicenceStruct
transactionid.s
id.s
serial.s
EndStructure
Global Client.AdresStruct
Global Profile.AdresStruct
Global Dim Licence.LicenceStruct(10)
Licence(0)\id = "person aaa"
Licence(0)\transactionid = "TR_1"
Licence(0)\serial = "ABC"
Licence(1)\id = "person bbb"
Licence(1)\transactionid = "TR_2"
Licence(1)\serial = "DEF"
Licence(2)\id = "person ccc"
Licence(2)\transactionid = "TR_3"
Licence(2)\serial = "GHI"
Client\naam = "aaa"
Client\straat = "bbb"
Client\gemeente = "ccc"
Profile\naam = "ddd"
Profile\straat = "eee"
Profile\gemeente = "fff"
If CreateJSON(0)
InsertJSONArray(JSONValue(0),Licence())
InsertJSONStructure(JSONValue(0),@Klant.AdresStruct,AdresStruct)
InsertJSONStructure(JSONValue(0),@Profile.AdresStruct,AdresStruct)
retval.s = ComposeJSON(0)
FreeJSON(0)
MessageRequester(retval)
Else
MessageRequester("Klant/profile/licence parse to json failed")
EndIf