Firebase database - how to create a list from array

Hi,
I’ve been struggling from some time and decided that without help I’m not gonna jump over this obstacle.
The question is how to create a list form arrays in firebase database.
I have a structure like in the image below:


I would like to get a list for first level (blue) and then based on that list go one step deeper and create another list (red).

This is the view of the blocks:


In a nutshell:

  1. I call the firebase
  2. When I receive data I save it to variable
  3. Use JASONTool extention to parse it
  4. Trying to go down the structure but I think I might be doing that wrong.

Huge thenks for any help :slight_smile:

You have to create the list in a list. It requires simple logic. The easiest way to do this is to iterate trough every tag in your bucket, and for every tag if it’s a list iterate again. If u don’t want to create a lot of loops you can use “list by walking key path” and make an additional variable which is list which holds your list level so two loops with break conditions should be enough.

The easiest way to store that kind of lists is:
tag 1) TinyDB: key: “SKŁADNIKI”; value: [N, O, P W]
tag 2) TinyDB: key: “W”; value: [W_DYN, W_LIS…, W_WIE]
tag 3) TinyDB: key: “W_DYN” value: “your value”

So every tindyDB tag stores the name of a list and its content.
If u call TinyDB tag with the name of SKŁADNIKI you get list, which every item in that list is stored in tinyDB tags.

If u don’t want to use any database system and only variable is in your interest it would get harder cause if u want to hold list name you have to make additional list in a list.

Hi,
first of all thank you for answer.
The thing is that the structure of the DB will grow and I would like to set the app in such way that I don’t need to make a correction each time the new record appears.
So the problem is not in the logic, I agree that it is simple :slight_smile: it is in the technical way to extract a list from array in JASON.
Right now I get parsing error:


The funiest thing is that I once did that, but for unknown reason in this app the same aprouch is not woking.

P.S. “Ł”? :smiley: Czyżby ktoś z kraju nad Wisłą?

Use dictionaries with the help of web JSON parse block.

This extention helped:

Thanks for the hint.

3 Likes

It can be a solution but it is a bit glitchy.

@Andrzej_J You can use get keys, get value at key (path)