# JSON to List Help

**URL:** <https://community.thunkable.com/t/json-to-list-help/47409>\
**Category:** Questions about Thunkable X\
**Created:** [September 18, 2018, 10:54am UTC](https://community.thunkable.com/t/json-to-list-help/47409 "2018-09-18T10:54:51Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_White](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@David\_White](https://community.thunkable.com/u/David_White)\
**Post date:** [September 18, 2018, 10:54am UTC](https://community.thunkable.com/t/json-to-list-help/47409/1 "2018-09-18T10:54:51Z")

</div>

Hello

I am struggling to query this JSON in Thunkable X. I can do it in app inventor.

Seems like it should be a simple thing to create a list of names from “name” field from this JSON.

Does anyone have any advice.

Thanks

 ![json](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/6/f68a15a8b4f11ec3587bf477d293c32dfeae698f.png)

---

<div class="post-metadata">

**Author:** ![Mike\_Fourway\_Flasher](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@Mike\_Fourway\_Flasher](https://community.thunkable.com/u/Mike_Fourway_Flasher)\
**Post date:** [September 24, 2018, 6:23pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/2 "2018-09-24T18:23:38Z")

</div>

I’m also looking for an answer to this issue. I can generate a list view if there is only a top level item in the database, but if there are children it doesn’t show anything.

Any help or pointing to an answer would be appreciated.

---

<div class="post-metadata">

**Author:** ![Techbot](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/techbot/32/11087_2.png) [@Techbot](https://community.thunkable.com/u/Techbot)\
**Post date:** [September 24, 2018, 9:13pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/3 "2018-09-24T21:13:47Z")

</div>

You’ll need to do some tutorials on lists and indexes to make sense of this. I built a small assistant that gives me weather…the code is in JSON and I had to pick each item I wanted her to speak from the list

 ![Capture](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/3/6318a883265b2cd582cd2c5483632144616b05b5.PNG)

---

<div class="post-metadata">

**Author:** ![David\_White](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@David\_White](https://community.thunkable.com/u/David_White)\
**Post date:** [September 25, 2018, 6:02am UTC](https://community.thunkable.com/t/json-to-list-help/47409/4 "2018-09-25T06:02:28Z")

</div>

So far all I’ve got is the blocks below, which return me the value of “The Timber Floor Centre”. My aim is a list “Red Rooster, The Timber Floor Centre”.

 ![blocks](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/f/af5ba7a4fdc7565f00188bfc1025ddf290341f36.png)

---

<div class="post-metadata">

**Author:** ![Techbot](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/techbot/32/11087_2.png) [@Techbot](https://community.thunkable.com/u/Techbot)\
**Post date:** [September 25, 2018, 2:07pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/5 "2018-09-25T14:07:46Z")

</div>

I’m still new to coding myself, but I’m not sure the “Object” blocks you have there are the best for what you’re doing. If you’re pulling from a JSON list, use the “List” blocks available. Again, you’ll have to sit down with the output and find the index numbers of each item you want. At least that’s what I was taught when doing my assistant

Try this link/tutorial for some good info about pulling items from a JSON list: [Easy to decode large information with JSON format](http://community.thunkable.com/t/easy-to-decode-large-information-with-json-format/6132?u=taifun)

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [September 26, 2018, 5:45pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/6 "2018-09-26T17:45:17Z")

</div>

@David_White, You’re on the right track! You probably want to create a variable somewhere and initialize it to be an empty list. Then add the value that you are currently assigning to your `listofplaceslabel` to that list using the `'in list __insert at last as__'` block. That way you’ll build up that list to contain all the place names.

-Mark

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [September 26, 2018, 5:47pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/7 "2018-09-26T17:47:56Z")

</div>

The Object blocks were created, in large part, to support dealing with JSON results from Web APIs, so I think it’s perfectly appropriate for David to use them here. The tutorial that you’re linking to is for Thunkable Classic, which doesn’t contain Object blocks.

-Mark

---

<div class="post-metadata">

**Author:** ![Techbot](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/techbot/32/11087_2.png) [@Techbot](https://community.thunkable.com/u/Techbot)\
**Post date:** [September 29, 2018, 5:28pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/8 "2018-09-29T17:28:51Z")

</div>

ahh! That’s good to know!

---

<div class="post-metadata">

**Author:** ![David\_White](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@David\_White](https://community.thunkable.com/u/David_White)\
**Post date:** [September 30, 2018, 10:28am UTC](https://community.thunkable.com/t/json-to-list-help/47409/9 "2018-09-30T10:28:53Z")

</div>

Thanks Mark. These blocks are creating the list I’m after. Depending on my location the JSON will have a different number of place names. How do you think I can set it up so it figures out how many place names there are and builds the list based on that?

 ![listofplaces](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/a/fa1f499c576616b6695b146e7059a1cffd1523e8.png)

---

<div class="post-metadata">

**Author:** ![Shakeel\_Hashim](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Shakeel\_Hashim](https://community.thunkable.com/u/Shakeel_Hashim)\
**Post date:** [October 2, 2018, 1:39pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/10 "2018-10-02T13:39:12Z")

</div>

Hi - I’m trying to do a similar thing to this with the Google Maps Search API. I’ve currently got my blocks set up like this: it adds the first result to the list, then looks to see if there is a second result, and if there is it adds that to the list. There’s a problem though: this works for a search result that includes 2 or more places, but displays nothing (not even the first result) if only one result is returned.

Do I need a different condition for the if/then statement, or is the problem elsewhere? Any ideas/help would be hugely appreciated.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/a/eaa5bceaed174cd14cd0fb57ba7a9f105027d074.png)

---

<div class="post-metadata">

**Author:** ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)\
**Post date:** [October 2, 2018, 4:25pm UTC](https://community.thunkable.com/t/json-to-list-help/47409/11 "2018-10-02T16:25:43Z")

</div>

David,

Looking at the JSON that you posted in your initial message it looks like the ‘results’ property is returning a list. Consequently, you can use any of the list blocks (e.g. `'length of'`) on the value returned by your `'get property results of object'` block.

BTW, you can tell from the JSON string that the ‘results’ property is returning a list because it begins with an open square bracket (i.e. “[”).

As a further note, while your `'get property 0 of object'`, `'get property 1 of object'` blocks work on the list (due to the way that the lists are implemented) it would be safer and more clear to use `'in list __get # 1'`, `'in list__ get # 2'` blocks instead. Note that when you refer to the items as a list, the items start at 1, rather than at 0 when you refer to them as an object property.

Hope this helps.

Happy Thunking!

-Mark

---

<div class="post-metadata">

**Author:** ![Shakeel\_Hashim](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Shakeel\_Hashim](https://community.thunkable.com/u/Shakeel_Hashim)\
**Post date:** [October 3, 2018, 11:49am UTC](https://community.thunkable.com/t/json-to-list-help/47409/12 "2018-10-03T11:49:04Z")

</div>

This solved my problem too - thanks Mark!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:55am UTC](https://community.thunkable.com/t/json-to-list-help/47409/13 "2024-11-08T11:55:18Z")

</div>


