Parse JSON file to dictionary

I have a JSON file with this structure (“key”: “value”) and I would like to read it and create a dictionary


I have read a lot of topics about this and test all methods that I’ve found but i’m unable to parse it correctly.
Can anyone help me please ?

Is this json file is stored in your assets or in the storage.Or you have it in a varibale.
Any way this extension would be useful:

P.S: You can use the file component read method

1 Like

You can use the file component to get the text (external storage use single slash, assets use double slash), then use @Mohamed_Tamer’s extension .

1 Like

Actually, I’ve already read this topic and tried this extension with the file component.
But the result was not good :confused:
The JSON file is in my assets.
My goal is, at the first run, to read the json file, put it in a dictionnary and store the dictionary in TinyDB.
On next runs, only have to get valur from TinyDB.

I try to mix this 2 examples (taken from Simple use of dictionary and TinyDB)

Test.aia (2.4 KB)

Thanks for your help,

but my dictionnary has to come from a Json file that is i my assets.

At the end I’d like to call a value like this

But i don’t what to do between the read from black and this one

Here’s how to use the file component to read json and then parse it.:

Actually, I already have a solution that works but each time I need a color I go to read the file.
And I think this method is very slow as the app has some lags.
So this is why I think that loading the json at first run to a dictionary stored in TinyDB should work better.

I have to reduce the read access, so I try to find a solution to read in memory (except for first get value from TinyDB)


  • read the json file and convert it to a dictionnary
  • save this dictionary to TinyDB


  • set a global variable with the saved dictionary (thanks to the tinyDB get value)
  • read the value from the variable (with “get value for key” block)

Okay so here’s another one:
Something like?

1 Like

Actually storing it in a variable is a good way instead of JSON file in assets.

1 Like

Test (3).aia (2.8 KB)

The first block is not necessary “Default Setting” Variable.

I don’t know if it works without these blocks.
blocks (48)

It might work, but the extension provided by @Mohamed_Tamer is the best for parsing Json text to dictionary.

1 Like

Hello guys,
First thanks for your help :wink:
I’m back after doing some tests.
Actually I’m facing (I think) an issue.
It seems that storing the dictionary to TinyDB takes some times and if I try to get value from it just after, the get value return nothing (maybe still doing the store value).
It is the same if I set my variable to the dictionary given with JsonTextDecodeWithDictionaries.

If I set only one variable, then the variable is ok
If I set 2 variable, the second is ok but there is nothing in the first :confused:

I put a timer to call a procedure that set the second variable and it works, but not with TinyDB method (that seems longer than just setting variables)

Blocks seems to not be executed sequentially…

Can you send out the code?

1 Like

I just tested with the variable method (which I suspect to be quicker than getting values from Ressource Utilities component) and it is not quicker at all. I tested on my old Motorola Nexus that is very slow.
So I stay with my initial work :confused:

By the way thanks for your time :wink:

Show blocks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.