Insert And Extract JSON Array and List Help
Posted: Sat Apr 11, 2020 8:55 am
Trying to insert an Array and a list into a single JSON file then extract them but hitting trouble.
Can anyone help?
Can anyone help?
Code: Select all
Structure Entry
Description.s
Width.i
EndStructure
Global Dim Album.Entry(10)
Structure Set
Margin.i
Border.i
EndStructure
Global NewList Settings.Set()
Global CurrentFileName.s
CurrentFileName = "Test.wca"
For iLoop = 0 To 9
Album(iLoop)\Description = "Item Number " + Str(iLoop)
Album(iLoop)\Width = iLoop
Next iLoop
AddElement(Settings())
Settings()\Border = 23
Settings()\Margin = 4
If CreateJSON(0)
iLoop = JSONValue(0)
InsertJSONArray(iLoop ,Album())
InsertJSONList(iLoop,Settings())
SaveJSON(0, CurrentFileName)
FreeJSON(0)
EndIf
If CurrentFileName
iLoop = LoadJSON(#PB_Any, CurrentFileName)
ExtractJSONArray(JSONValue(iLoop), Album())
EndIf
For iLoop = 0 To 9
Debug Album(iLoop)\Description
Next iLoop