Parse a json file

I have the following json file:

{“status”:0,“texto”:“Weiz”,“localidad”:[{“id”:195911,“nombre”:“Weiz”,“nivel”:4,“jerarquia”:[“Steiermark”,“Österreich”,“Europe”],“pais”:164,“bandera”:“:austria:”,“url”:“"},{“id”:195159,“nombre”:"Puch Bei Weiz”,“nivel”:4,“jerarquia”:[“Steiermark”,“Österreich”,“Europe”],“pais”:164,“bandera”:“:austria:”,“url”:“"},{“id”:194638,“nombre”:"Kulm Bei Weiz”,“nivel”:4,“jerarquia”:[“Steiermark”,“Österreich”,“Europe”],“pais”:164,“bandera”:“:austria:”,“url”:“"}],“mensaje”:"”}

I will need the id and nombre
for example id: 195911 and nombre: Weiz

I have tried the following for the id:
blocks (1)
But I will get the following message when I want save the result in a label:

Hope somebody can help me.
kindly regards

use Do it to debug your blocks, see also tip 4 here
see also Live Development, Testing, and Debugging Tools

Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

Thanks for the answer.
I have tried the Do it. But when I insert the same json value I will get the same error.
Hope somebody can still help me how I can parse this json file correctly.
kindly regards

  • Local variables are terrible for debugging.
    They evaporate before you can examine them in a debugger.
  • Use global variables instead.
  • Do not reuse the same global variable as you work your way in from the outside inwards.
    They are like footprints to a detective. don’t sweep them away behind you.
  • Name a new global variable for each step along the way, usually by tag.
  • Don’t ignore [ ] marks, they produce lists instead of objects, so you need select item from list at that level.
  • This board fouls up " " marks, they have to be translated back into straight quotes.

Thanks for your answer.
Here is my test to start the function to parse the json.
blocks (2)
I tried a list but with the same error.
When I search only for the status or texto it is no problem.
For example the status:
blocks (3)
blocks (4)

Hope somebody can still help me how I can do this if id and nombre

Here is how to get all the id and nombre pairs…
JSON_sample1.aia (3.3 KB) when button1 click


You may want to use the Web1.JsonTextDecodeWithDictionaries, which will return a dictionary object rather than a list of lists.

This is what I understood, you write an id and you get its nombre.

borrar_jsonId.aia (3.1 KB)