I hope, you can help me with working with a JSON-structure, as I do not quite understand how to work with the JSON-Library.
The setup:
I do have a PHP-endpoint, which returns the following JSON-object:
Code: Select all
{
"Category AAA": [
{
"id" : 0,
"Name": "Product A",
"Punkte": 1,
"Einheit": "g",
"Menge": 100,
"Notiz": "Foo Bar Braz"
},
{
"id" : 1,
"Name": "Product B",
"Punkte": 2,
"Einheit": "pcs",
"Menge": 2,
"Notiz": "Dang Ding Dong"
},
{
"id" : 2,
"Name": "Product C",
"Punkte": 3,
"Einheit": "ml",
"Menge": 30,
"Notiz": "Erl Ferl Gerl"
}
],
"Category BBB": [
{
"id" : 3,
"Name": "Product D",
"Punkte": 4,
"Einheit": "g",
"Menge": 10,
"Notiz": "Hart Smart Fart"
},
{
"id" : 4,
"Name": "Product E",
"Punkte": 5,
"Einheit": "pcs",
"Menge": 10,
"Notiz": "Irre Quirre Schmock"
},
{
"id" : 5,
"Name": "Product F",
"Punkte": 6,
"Einheit": "ml",
"Menge": 1000,
"Notiz": "Junk Funk Skunk"
}
]
}If I work with very basic / single Key-Value pairs, it's not a problem, but the nesting drives me crazy.
Code: Select all
Enumeration
#JSON_DATA
EndEndumeration
Procedure loadData(Success, Result$, UserData)
If Success
ParseJSON(#JSON_DATA, Result$)
ObjectValue = JSONValue(#JSON_DATA)
If (JSONMemberKey(ObjectValue) = "Category AAA")
; ==== ????
EndIf
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
HTTPRequest(#PB_HTTP_Get, "http://test.local/get_data.php", "", @loadData())