Reputation: 1693
I have a JSON string which I can parse with Corona SDK. What I could not figure out yet is how to use the return value and assign it to a variable which I can access later?
I get the JSON string in this function:
local function networkListener( event )
if ( event.isError ) then
print( "Network error!")
else
print ( "RESPONSE: " .. event.response )
end
end
The return value looks like this:
[{"id":"25761","name":"Legend Of Zelda: Ocarina Of Time 3D, The","cnt":"15"},{"id":"26106","name":"Zelda No Densetsu: Toki No Ocarina 3D","cnt":"15"}]
How can I make a table from that return value? Thanks
Upvotes: 1
Views: 2627
Reputation: 1271
require "json"
local t = json.decode( jsonFile( "sample.json" ) )
Exploring JSON Usage in Corona
Upvotes: 3