how I can parse in structure and load-save from-to file example "client,json"
Code: Select all
{
"proxy": "",
"priority": "Z",
"books": [{
"type": "text",
"id": "text",
"label": "text",
"value": "text"
}, {
"type": "text",
"id": "text",
"label": "text",
"value": "text"
}, {
"type": "text",
"id": "text",
"label": null,
"value": true
}],
"lang": 1
}
Code: Select all
Global WorkPath$ = GetPathPart(ProgramFilename())
Global ClientsFile$ = WorkPath$ + "client.json"
Structure CLIENT
proxy.s
priority.s
Array books.s(200)
lang.l
EndStructure
Global CL.CLIENT
; Load
If LoadJSON(#JSON_Load, ClientsFile$)
ExtractJSONStructure(JSONValue(#JSON_Load), @CL, CLIENT)
Debug CL\priority
Debug CL\books(1) ; ????
FreeJSON(#JSON_Load)
EndIf
; Save
If CreateJSON(#JSON_Write)
InsertJSONStructure(JSONValue(#JSON_Write), @CL, CLIENT)
SaveJSON(#JSON_Write, ClientsFile$, #PB_JSON_PrettyPrint)
FreeJSON(#JSON_Write)
EndIf