How to get JSON ID from an JSON Object

The above question posed in 2019 has an elaborate method to do what I want. My hope is in the past 4 years there might be a simpler way to do it, like “get json object id”. Following is the JSON object:

In this I want a list generated looking like this: [temperature, wind, description, forecast[{day, temperature, wind}, {day, temperature, wind},{day, temperature, wind}]. Basically I am accessing a URL where I don’t know what ID’s to expect. First I need to get the ID then its properties. My sample program:

if you are trying to write a general purpose routine for converting ANY json string tnto a list, which could contain another list as an item, etc, using thunkable - good luck!

while there is indeed a block for getting the variable names (what you call jsonId), there is no way -using thunkable - to determine what data class each item is (ie, string, integer, real, date?).

and the only way to determine if an item is a list, is to obtain the object then get its length - if greater than zero, it’s an array. and you have to be able to that recursively (ie.list of lists of lists of lists … etc).

i was able to convert your json example

  "temperature": "+31 °C",
  "wind": "4 km/h",
  "description": "Sunny",
  "forecast": [
      "day": "1",
      "temperature": "31 °C",
      "wind": "7 km/h"
      "day": "2",
      "temperature": "+32 °C",
      "wind": "20 km/h"
      "day": "3",
      "temperature": "+32 °C",
      "wind": "19 km/h"

the same data above is minified into this string

{"temperature":"+31 °C","wind":"4 km/h","description":"Sunny","forecast":[{"day":"1","temperature":"31 °C","wind":"7 km/h"},{"day":"2","temperature":"+32 °C","wind":"20 km/h"},{"day":"3","temperature":"+32 °C","wind":"19 km/h"}]}

… into a list using this block:

… and it does its thing and it creates the list in variable rlist but if you display the list, it’s confusing because thunkable doesn’t use any symbol for indicating start or end of arrays.

while you’re expecting this, an array of 4 items where the 4th item is an array of 3 arrays!

[+31 °C,4 km/h,Sunny,[[1,31 °C,7 km/h],[2,+32 °C,20 km/h],[3,+32 °C,19 km/h]]]

you get this instead:

internally, thunkable knows where the items are but you wouldn’t be able to debug it visually because there are no clues where the array starts or end.

for example, this block segment

display the 2nd entry in the forecast array correctly.

you still have to parse it to get the individual parts of course.

here’s the version i played with:

1 Like

Thankyou Manyone you have given me lot of good ideas. So in general Thunkable does not have a well known easy way of getting only the JSON ID’s(Or name). My problem is when I access a URL I do not know what name to put in the “get property(xxxx)”. xxxx is unknown and xxxx can change in the given URL and JSON object might have more or less of the JSON ID’s. I cannot assume constant count or name. I will check what you have done and see if I can end up with just the JSON ID’s. Thanks a lot

Hi Manyone,

The link you sent connects to my own app not to yours. It does say Web_API_Test but does not have any new code. Please resend.


can you try this?

Sorry no I keep getting mine. Please change the name to XXX and reshare it. Thanks

sorry about that - how about now

1 Like

Got it!! :pray: :pray: Will use it as my base. When I am done will post the solution.

dont forget to use this

it will return this:

new link (includes above block)

1 Like

Hi Manyone,

Thanks for your help, idea and framework, I have to fully working as I want. The URL is very weak and keeps dying so just as you did I have hardcoded the data for a proof of concept.
The link to the program just does not work despite the fact I have no URL connected to the program. I keep getting the error message of OpenGraph tags. So I have enclosed the image of it.

Thanks again for the help

i don’t understand, when i run your project and click on button , i get the display below… isn’t this the outcome you expect?

Yes I was just reporting back to tell you it is all done and closed. Sorry I had forgotten to click the Solution box. Just now I clicked it. It is all done and closed. Thanks

1 Like

great job!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.