Just starting out? Need help? Post your questions and find answers here.
User avatar
Arbrakaan
 
Posts: 64
Joined: Mon Feb 24, 2014 10:54 pm
Location: Geneva

JSON - ExtractJSONList()

by Arbrakaan Tue Oct 23, 2018 9:39 pm

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 :)
User avatar
Peter
 
Posts: 553
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: JSON - ExtractJSONList()

by Peter Wed Oct 24, 2018 5:13 am

replace the single quotes with double quotes.

Greetings ... Peter
User avatar
Arbrakaan
 
Posts: 64
Joined: Mon Feb 24, 2014 10:54 pm
Location: Geneva

Re: JSON - ExtractJSONList()

by Arbrakaan Wed Oct 24, 2018 7:33 am

Hurg.... :D

Thanks Peter for the quick answer ;)
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 2 guests