Page 1 of 1
ExtractJSONMap() problem
Posted: Tue Dec 12, 2023 1:12 am
by tua
Code: Select all
Input$ = "{" + Chr(34) + "14" + Chr(34) + ": " + Chr(34) + "Joe" + Chr(34) + "," +
Chr(34) + "22" + Chr(34) + ": " + Chr(34) + "Jim" + Chr(34) + "," +
Chr(34) + "5" + Chr(34) + ": " + Chr(34) + "Mark" + Chr(34) + "}"
j = ParseJSON(0, Input$)
If IsJSON(j)
NewMap Options()
ExtractJSONMap(JSONValue(0), Options())
ForEach Options()
Debug MapKey(Options()) + Options()
Next
EndIf
This does not print out the key/value pairs I am expecting here, but rather the numbers: 140, 220, 50 - i.e. my keys multiplied by 10. What am I missing?
Re: ExtractJSONMap() problem
Posted: Tue Dec 12, 2023 1:48 am
by normeus
The map should be a string type:
Code: Select all
Input$ = "{" + Chr(34) + "14" + Chr(34) + ": " + Chr(34) + "Joe" + Chr(34) + "," +
Chr(34) + "22" + Chr(34) + ": " + Chr(34) + "Jim" + Chr(34) + "," +
Chr(34) + "5" + Chr(34) + ": " + Chr(34) + "Mark" + Chr(34) + "}"
Debug input$
j = ParseJSON(0, Input$)
Debug JSONErrorMessage()
If IsJSON(0)
NewMap Options.s() ; <------------------------ string
ExtractJSONMap(JSONValue(0 ), Options())
ForEach Options()
key$ = MapKey(Options())
Debug Options(key$)+" "+ key$
Next
Else
Debug "NO JSON"
EndIf
Norm.
Re: ExtractJSONMap() problem
Posted: Tue Dec 12, 2023 1:55 am
by tua
Yes, it should!

Thanks!