[Solved] How do I parse JSON Object

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 :frowning: .

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.

Can anyone help? I am tearing my hair out!

I have done some more digging and have the following.

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.

1 Like

@tatiang thanks for responding. I have watched your video and made some changes but still no luck :frowning:
I have accessed the api using a web page:

I have used the JSON formatter you use to validate it:

If I execute the following block:

I get this:

but if I plug in the json extract block as follows:

The app just crashes and disappears:

Any other ideas? Anyone?

1 Like

You are confusing the system. Avoid using similar block/variable names. Change Response to something else such as responseText

@muneer thanks, unfortunately no change:

It works if I remove the object block and crashes if I leave it in

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.

1 Like

@Claus_Holbech1 thank, this is great news, kind of :wink: at least I am not going mad.

How do you contact support?

Via online chat from the builder. (I have pro subscription).

2 Likes

Mine was working just yesterday, but today it just crashed when I tested it.

1 Like

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}

1 Like

@lamagalhaes How did you discover the extra wrapper?

showing an alert: image

2 Likes

Hey all:

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.

2 Likes

Me too! Would be good to have a current bug list somewhere. Any idea how long it might take?

it seems to be fixed now!

3 Likes

Hi everyone,

I would like to confirm that the issue with the ‘get object from JSON’ block was resolved within a few hours.

Thanks to everyone who reported it!

3 Likes

It appears I still have this problem. It seemed to be solved a few days ago, but now my project crashes again in Thunkable Live.

In particular, I have the issue using the block get object from json.

Anyone still having this issue?

1 Like

So no API calls are working for you once you try to parse the JSON? Or is it just a particular property?

1 Like

To test the previous condition with the Get object from JSoN block do the following


Both Label1 and Label2 should show similar results.

If there is a problem with the Get object from JSON block, the second label will show empty curly brackets {}.