Hello, I am sorry I do not have any code as of yet… I plan to post a solution here so people can get started with JSON quickly.
In the mean time would people like so share/point me in the direction of decoding/encodeing JSON strings in lua. Wither there are ready made solutions or manual parsing is required…
@Ruttyj That library wasn’t made by you, was it? I recognize it from Briarfox using it in AutoGist. Also, it’s not made for Codea, just generic Lua. And the term to use for it is module, not library. It would normally use the import function to load it.
I would also wish to learn how to use JSON due to collecting data from a web site and use it in the app I have started. I have read some of the threads but as yet have not understood it.
@Briarfox. Have tried your solution and still nothing.
Function setup()
http.request (“website”,yesdata)
End
Function yesdata(data,status,headers)
Print(status…“:”…data) – prints out the data from the website
Local tbl=json.decde(data)
Print (table.maxn(tbl)) – prints 0
End
Could you please point out where I have gone wrong
Thanks for your help @Briarfox the solution works and it prints out all the infomation from the web site. All I have to do is learn how to manage the data and store it into an array I can use elsewhere in the app.
The above is a sample taken from a http call.
I am trying to decode the above using json decoder. I have tried various things and the problem I am encountering is the 3rd item. Decodes the x and y but when it gets to the “Names” it just returns a table.