Hello
I was loading values from a JSON data feed with no problems
JSON
{"data":[{ "id":1, "main":"Title goes here", "description":"Description goes here", "icon":"10d" }]}
At first I could not read values inside the square brackets (json.decode returned nil) so I ran a gsub to remove the square brackets then saved the json then decoded it.
savedData = string.gsub (savedData, "%[", "") savedData = string.gsub (savedData, "%]", "")
I could then decode just fine.
tostring(\_G.myjsonobj.data.description))
Now my problem is i am encountering JSON that looks like this
{"data": [{ "id":1, "main":"Title goes here", "description":"Description goes here", "icon":"10d" }, { "id":2, "main":"Title goes here", "description":"Description goes here", "value":"2" }]}
When I try and read say description after decoding the Json it is a nil value?
Is there a way to read the first portion (e.g tostring(_G.myjsonobj.description(0))) )
You can see how I read from JSON in a helpful reply I left here
http://forums.coronalabs.com/topic/49659-a-question-on-json-files/?p=258086
Thanks