Code: Select all
Structure _Product
base_cost.i
spoil.i
weight.i
EndStructure
Define json$ = ~"{\"water\":{\"base_cost\":10,\"spoil\":-1,\"weight\":1}}"
ParseJSON(0, json$)
Define value = JSONValue(0)
Define water._Product
If ExamineJSONMembers(value)
While NextJSONMember(value)
Define subvalue = JSONMemberValue(value)
InsertJSONStructure(subvalue, @water, _Product)
; ExamineJSONMembers(subvalue)
; While NextJSONMember(subvalue)
; Debug JSONMemberKey(subvalue) + " = " + GetJSONInteger(JSONMemberValue(subvalue))
; Wend
Wend
EndIf
Debug water\base_cost
Debug water\spoil
Debug water\weight
I've actually tried the following first, as it sounds more logic to me:
Code: Select all
InsertJSONStructure(value, @water, _Product)But then the program seems to hang in an infinite loop.
EDIT: The idea being that the JSON file would have more products, and that each product would be stored inside a map.



