Just starting out? Need help? Post your questions and find answers here.
tua
User
Posts: 68 Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada
Post
by tua » Tue Dec 12, 2023 1:12 am
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?
normeus
Enthusiast
Posts: 477 Joined: Fri Apr 20, 2012 8:09 pm
Contact:
Post
by normeus » Tue Dec 12, 2023 1:48 am
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.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
tua
User
Posts: 68 Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada
Post
by tua » Tue Dec 12, 2023 1:55 am
Yes, it should!
Thanks!