Creating a proper JSON list using Objects

I thought I should share blocks on how to create a proper JSON list using Object because I had scoured the community for a solution and hadn’t found one

6 Likes

Thanks for this, how do you retrieve this list and display it in a listview?

Exactly

@Bobby @farhanlatif027i3df

I suggest you guys do a lot more form posts. In addition, when you post, you should include what you have tried so far. This will help you receive the assistance you are seeking. It’s not that the help you seek isn’t always available, but you are casting wide nets with questions like that. Also, your answers are likely already answered in previous posts. Please search the forums and read through the posts thoroughly before posting or commenting on posts. If you have done this, I apologize but it seems like you maybe haven’t done it yet or are having trouble understanding what’s been posted. If that is the case, mention that you don’t understand.

Screen Shot 2020-02-06 at 1.54.09 PM

1 Like

Here are my blocks and a shot of my DB. I swear I put these up a few days ago. I must be going crazy.

you are asking for property j of object value. switch those blocks around in your GET call

you want to ask for property “name of property” of object j

Screen Shot 2020-02-06 at 5.19.43 PM

like this

Screen Shot 2020-02-06 at 5.21.00 PM

when you save you want to use a block like this

looks liek you should be asking for property list of object j in these blocks you posted above
Screen Shot 2020-02-06 at 5.27.50 PM

thanks @jared. I switched it around but it is still not displaying the values from the db when I view the list in my app.

have you pulled the error block out to see if you are recieving one?

I would think these blocks would work

1 Like

What would cause the value to display this way? It seems like each character is displaying in its own row.

Hello,
Sorry to revive an old topic, but I am having issues with creating Objects properly. This is my first time ever working with FIrebase and JSON besides just loading a JSON file that already exists into OBS. Here is what I got.

I am connected to Firebase. When I get the values I want from the Firebase tree, I have them being displayed on a label. The label does correctly show the string of values from the get. However, I am getting errors when I run the FOR loop and then move to the next screen. The next screen has a list viewer which pulls from the data table Home Options (referenced in the blocks). If I remove the FOR loop, the next screen doesn’t error out, but it shows the list viewer doesn’t have any data. I am assuming the FOR loop is returning NULL, and that is causing the error.

Here is my code and Firebase tree. The Tree is directly located under the main branch, I just didn’t include the URL. Does anyone have any insight on how to properly load my data?


1 Like

Firebase Get block retrieves data as object not as JSON.

To see the “Value1”,“Value2” you can simple use “get properties of object” which you can assign it to a List Viewer.

Your can then access each of them by the “get property of object”

I understood this from your replay, but I am still getting the error on the Data List Viewer. The test textbox is showing “Value1,Value2” as expected. What am I doing incorrectly? I am trying to set the data in the Home Options table to Pic and Value, which are properties of Value1/2.

So the data I am looking for in my DLV is “Test” with the pic, and “Test2” with the pic.

1 Like

What you did is correct. The only issue you need to be aware of is that “get object properties of” does not retain the object but instead creates a simple list.

Therefore in the create row the values of the row will have double “get property of object”.

It would be

Get property 'pic' of object
             Get property j of object value

This should give you the proper data stored under ‘pic’

Do the same for the other item.

Sorry, I’m replying to you from the mobile therefore not able to show blocks.

1 Like

Thank you! It worked. For other’s reference, here is what I did, and it is working successfully.

1 Like

This a great article. There needs to be an official article like this on Thunkable docs.

Maybe there is but I haven’t seen it. If there is, please point me in that direction. Thanks.

Either way, thanks all for sharing.

2 Likes