Look up in pairs problem

Hey!

I have got a beginner question that I can´t answer. I guess it will be quite obvious, but I am stuck. So sorry for asking :slight_smile:

So I am asking my Firebase Realtime Database for the value with the tag "Test".
It delivers: [{KH=5, EW=10, FE=20, Name=Testy}. So a List?

Now I am trying to get the value for "name". I used the "look up in pairs" function, with get(value) as pairs and "name" as key.

It gives me the runtime error:
The operation lookup in pairs cannot accept the arguments: , ["KH"], [{KH=5, EW=10, FE=20, Name=Testy}], ["no info"]

I cant figure out why. Can you please help me?
Sorry for this basic question, I am just starting out and cant figure out where to look.

You received a JSON text.
Please read

1 Like

Thank you both :slight_smile:

I will have a closer look at json files, but its too much right now.

With @TIMAI2 s answer I still get an error message when pressing "do it" on the "call web 1...":
"Error from Companion: invoke: no method named ´JsonTextWithDictionaries´in class com.google.appinventor.componens.runtime.Web"

What do I do?

It sounds like your companion app is out of date if that is the case. The JsonTextDecodeWithDictionaries block was added when we added the dictionary type to the blocks language. This was done in nb182 back in February of this year. If you haven't already, consider updating your companion app via the Play Store or by downloading the latest version from the App Inventor server scanning the QR code under the Help > Companion Information menu option.

Thanks :slight_smile:

When I run the "select list item" function, I now get the error:

"Lookup in pairs: the list ["EW", 10] is not a well-formed list of pairs"

Looks like a pair to me?

I solved the issue by selecting item 2 from the list. But is that failproof enough?

Please download and post each of those event block(s)/procedures here ...
(sample video)

Okay here it is :slight_smile:

It does somewhat work like this. Until I add data on my server and the order changes. Then the index changes as well. What do I do?

What does "value" look like - exactly.

Refer back to my example where it uses a key:pair, therefore the index (2) is not necessary

Use the right tool for the right job.

If it's got pairs {tag:value,...} use the dict lookup by key block
If it's got pairs [[tag,value],...] use the lookup in pairs list block
If it's a list [?,...] of similar items without tags, use a for each item in list block or a select item n from list block.

5 posts were split to a new topic: Response code vs response content