Getting Data From FirebaseDatabase in Dictionaries to List OF List

Hi everyone,

I’m trying to fetch user data from Firebase and turn it into a list of lists in Kodular.
My Firebase structure looks like this:

{
  "All User's": {
    "J1R1N2nerAbKnpcO3OPjo0iKaKD3": "{\"PushId\":\"9aeae157...\",\"UseName\":\"Maybe\",\"User Profile\":\"http://...jpg\",\"UserID\":\"J1R1N2...\",\"Email\":\"email2@gmail.com\",\"Country\":\"GB\"}",
    "lFy1n1mYF2ZHQntrTTdwZ4oV6ax1": "{\"PushId\":\"b8b610a6...\",\"UseName\":\"Johnny\",\"User Profile\":\"http://...jpg\",\"UserID\":\"lFy1n1mY...\",\"Email\":\"email7@gmail.com\",\"Country\":\"GB\"}"
  }
}

What I’ve done so far,

  • I used Firebase_Database1.GetValue with the tag "All User's".
  • In the GotValue event:
    • I check if tag = "All User's".
    • Then I set global AllUsers to an empty list.
    • I decode the value with JSONTextDecode(value) and store it in mainDict.
    • Then I loop for each key in dictionary mainDict.
    • Inside the loop


The problem:

It only gives me one user, even though my Firebase has more than one.
I can see both user IDs in the Firebase structure, so I’m sure the data is there.

What I think,

Maybe the value I get from Firebase is still text, not a dictionary.
I tried decoding twice (first for value, second for userText), but it still only returns one user.

Can someone please explain exactly where I might be going wrong, or how to properly loop through all the users in "All User's" and build my list of lists?

Thanks in advance!

Hi dear,

The problem is in how your data is saved on Firebase.
If you see, there are many \, meaning you have an All Users dictionary that contains two uid keys, but they don’t contain a properly formatted dictionary.
To fix this, as soon as you receive the data, you need to loop through the dictionary and format each key to turn it into an actual dictionary.

{
“All User’s”: {
“J1R1N2nerAbKnpcO3OPjo0iKaKD3”: {
“PushId”: “9aeae157…”,
“UseName”: “Maybe”,
“User Profile”: "http:
“UserID”: “J1R1N2…”,
“Email”: “email2@gmail.com”,
“Country”: “GB”
},
“lFy1n1mYF2ZHQntrTTdwZ4oV6ax1”: {
“PushId”: “b8b610a6…”,
“UseName”: “Johnny”,
“User Profile”: “http://…jpg”,
“UserID”: “lFy1n1mY…”,
“Email”: “email7@gmail.com”,
“Country”: “GB”
}
}
}

If your fb data in this format then it is quite good and you can take the two users id using get key methid

:thinking::thinking::thinking::thinking::thinking:What is happening here?

To save data correctly, it’s better to use the web component.
This guide by Tim explains everything perfectly.

1 Like

I censored the emails that contained addresses belonging to real users.

@Audiora_Streams, Make sure it doesn’t happen again, thanks

1 Like

The operation dictionary recursive set cannot accept the arguments: , [mct4IoonlgQAKmZwmxcE7NAiTyK2], [{}], [{“Country":“GB”,“Email”:"test@gmail.com”,“PushId”:“8f1a285e-373c-4302-bbeb-e2a3d11f97d4”,“UseName”:“Victor”,“User Profile”:“http://res.cloudinary.com/dssynxqr3/image/upload/v1760885063/bo3wtpzaywqoso5fkc5p.webp”,“UserID”:“mct4IoonlgQAKmZwmxcE7NAiTyK2”}]

Now am facing this issue

My goal is to fetch all data in this bucket

??

Have you tried it?

I don’t understand anything from that page, isn’t there anyway of storing and getting these data using Firebase component, @Still-learning @RaYzZz @Ibrahim_Jamar help me

I used your data, and it works correctly.

{
	"J1R1N2nerAbKnpcO3OPjo0iKaKD3": "{\"PushId\":\"9aeae157...\",\"UseName\":\"Maybe\",\"User Profile\":\"http://...jpg\",\"UserID\":\"J1R1N2...\",\"Email\":\"email2@gmail.com\",\"Country\":\"GB\"}",
	"lFy1n1mYF2ZHQntrTTdwZ4oV6ax1": "{\"PushId\":\"b8b610a6...\",\"UseName\":\"Johnny\",\"User Profile\":\"http://...jpg\",\"UserID\":\"lFy1n1mY...\",\"Email\":\"email7@gmail.com\",\"Country\":\"GB\"}"
}


But here still throwing the same error

The operation dictionary recursive set cannot accept the arguments: , [J1R1N2nerAbKnpcO3OPjo0iKaKD3], [{}], [{“Country":“GB”,“Email”:"email2@gmail.com”,“PushId”:“9aeae157…”,“UseName”:“Maybe”,“User Profile”:“http://…jpg”,“UserID”:“J1R1N2…”}]

hmm, strange :scream:

I don’t know what happening, now i have changed it into

{
“All User’s”: {
“B7Do0o8BoyWx4E657sNBCF5X5eC2”: “["daad4609-82b4-404c-ae28-477a6db9dcb9","Victor","http:\/\/res.cloudinary.com\/dssynxqr3\/image\/upload\/v1760889915\/e5rbugfjihqslxwzg1k6.webp","B7Do0o8BoyWx4E657sNBCF5X5eC2","Testemail@gmail.com","GB"]”,
“wYXQuSDGStTROoJHtHWW4C0JFok2”: “["6ec5b149-fec4-4511-a0fe-ad322385c285","Victoria ","http:\/\/res.cloudinary.com\/dssynxqr3\/image\/upload\/v1760889841\/ivsrt2qnvzq6kapilffv.webp","wYXQuSDGStTROoJHtHWW4C0JFok2","Testemail3@gmail.com","GB"]”
}
}

Am able to get the Json


But am enable to all user info into a list,

After tried this method it works, Thank guy your support @RaYzZz salute

I’m glad you solved it,

but unfortunately, this way you’ll make a lot of unnecessary requests to the database.
If you have 50 tags, 50 requests will be executed.
Multiply this by the number of clients, and the number of requests will skyrocket.

I understand that, but how can I fetch this kind of data recommend way, guide me please.

You can guide me from data storing structure and data fetching

Unfortunately, the Firebase component isn’t very good at saving data that isn’t simple text.
You could try using some extensions, otherwise, check out Tim’s guide (Please don’t say it’s unclear, it’s perfect :grin:)