Page 1 of 1

JSON - ExtractJSONList()

Posted: Tue Oct 23, 2018 9:39 pm
by Arbrakaan
Hello all,

I don't understand why this show noting in the debugger.

Code: Select all

Input$ = "[{'id':'0','name':'Daniel'},{'id':'1','name':'Pierre'},{'id':'2','name':'Jean'}]"
  
  Structure Location
    id.s
    name.s
  EndStructure
  
  NewList Locations.Location()
  
  ParseJSON(0, Input$)
 
  ExtractJSONList(JSONValue(0), Locations())
  
  ForEach Locations()
    Debug Locations()\id + ", " + Locations()\name
  Next
  
I took the same structure of code as in the SpiderBasic exemple : ExtractJSONList()

Code: Select all

  Input$ = "[ {" + Chr(34) + "x" + Chr(34) + ": 10, " + Chr(34) + "y" + Chr(34) + ": 20}, " + 
             "{" + Chr(34) + "x" + Chr(34) + ": 30, " + Chr(34) + "y" + Chr(34) + ": 50}, " + 
             "{" + Chr(34) + "x" + Chr(34) + ": -5, " + Chr(34) + "y" + Chr(34) + ": 100} ]"
  
  Structure Location
    x.l
    y.l
  EndStructure
  
  NewList Locations.Location()
  
  ParseJSON(0, Input$)
  ExtractJSONList(JSONValue(0), Locations())
  
  ForEach Locations()
    Debug Str(Locations()\x) + ", " + Str(Locations()\y)
  Next


Thanks for the help :)

Re: JSON - ExtractJSONList()

Posted: Wed Oct 24, 2018 5:13 am
by Peter
replace the single quotes with double quotes.

Greetings ... Peter

Re: JSON - ExtractJSONList()

Posted: Wed Oct 24, 2018 7:33 am
by Arbrakaan
Hurg.... :D

Thanks Peter for the quick answer ;)