Hi, I am new here so am afraid I must be doing something wrong but can’t seem to see it, so asking for some help.
I have been trying to access a web-api of my own but it keeps crashing when I try to parse the JSON object which the API returns. I simplified the response so that it was just a single token {“securitytoken”:“AAAAAAAAAAAAAAAAAAAA”} but even this wouldn’t work so I gave up with my api and tried to access the weather api from the tutorials and still it won’t work .
I have the following code attached to a button press:
When I run it I get a 200 response code and the whole JSON object shows in the message box - so far so good. However if I plug in the object parsing block the appt just crashes and I get nothing.
It seems pretty simple now but it’s still not working. I have tried looking at the other sample programs but notice they have a slightly different “buildingblock” for the getProperty action so not sure if that is related to it.
When I put the response object natively it shows the full response beginning Response=({“coord”:…
When I put get property main of object get object from json response it shows Response() i.e. it seems blank
When I put get property temp of object get property main of object get object from json response it crashes.
I just posted a tutorial that explains how to parse JSON. I recommend watching it:
The “main” property is a container for several other properties. Technically speaking, it’s an object rather than a name:value pair. So what you have is a start but it’s not correct. In the video, I explain how to traverse the JSON hierarchy and find the correct properties and their associated blocks.
I think there is a general problem with the get object from JSON block.
I got this reply from thunkable support earlier today:
Hi Claus, thanks for reporting this. It seems that the ‘get property of object’ block works fine when working directly with an object, so there may be an issue with the ‘get object from JSON’ block. I’ll ask the team to take a look.
Same problem here!
After several tests, the problem is in the “get object from JSON” block.
The json needed is within some strange another json: {"_U":0,"_V":1,"_W":{“abc”:123,“teste”:999},"_X:"null}
Thunkable tells me there is a bug right now with the getJSON block, so I would avoid it until they publish a fix. I spend many hours and lost a lot of hair to this, and I can’t figure out if this kind of thing is consolidated anywhere in the forums so I thought I’d share.