I have a chunk of code that works just fine
if ( event.isError ) then print( "Network error!") local newText = display.newText("Sorry, offline :(",150,10, "sega.ttf", 20) else print ( "\n>>>>>>>>>>>>> Response from api : " .. event.response ) local reply = display.newText(event.response,40, "sega.ttf", 25) local reply= json.decode(event.response) for k, v in pairs(reply) do ---print( k, v ) gold = v end
The code however throws an exceptions when it doesn't get json back. Today my api was returning an internal server error in html and my code of course failed.
How can I validate that the reply was actually valid json? I don't see any validateJson() function in the json library/