Can't retrieve data from json

Hi Koders
I’m facing a strange problem retrieving data from a json. I have a simple json file with some asana names and their duration in miliseconds (attached in zip file). The json had been validated in some places like this one JSON Validator - JSONLint tool to validate JSON data and can’t find a problem.
duration.zip (1.7 KB)
The block for retrieve the duration of the asana with the name is this one:


But I always get this with the apk:

Because the procedure can’t find the text string, but if I make a search manually the string is there!
Any idea of where the problem is? Because I tried everything and can’t make it work.
I have worked with json files for translation of the app and never had a problem like this.
Thanks in advance!

The first time you run it tinydb is empty. so resourse sets to not found and sets value to es which can not be divided by 0

2 Likes

It would be easier to use dictionary blocks and web component along with file component to read json file

2 Likes

Sorry Dora, I don’t understand; variable “AsanaName” is settled in the previous step, so the value is not empty, is it?
The value in Tiny_db is the picture of the asana, that is used to get the sound file name, changing the extension.
I tried step by step with Companion and the value was not empty.

This way a json file can be “transformed” into a dictionary? I will try this.
Thanks so much, Dora.

Also make sure that you request correct values from json , for example see the keys you have

2 Likes

Finally I found the problem; one of the names of the asanas that I was using to test was misspelled in the json file and it was the one that was the cause of the error!
Anyway, I learned how to get a dictionary from a json file and this is always a good thing.
Thanks for your help, Dora.

1 Like

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