How do I extract chemistry data from this JSON?

So I found a really cool JSON in GitHub here.

I am just wanting to convert it into an app like this, but I don't know how.

Any ideas?


:arrow_up: Steps to Make It Work :arrow_up:

  1. Copy the JSON text from the GitHub file and paste it in a notepad. Save the notepad text as elements.json file.
  2. Import the JSON file in the asset of AppInventor. Add the Web and File component to the project then place this code.
  3. After doing this, you can see that when the Screen1 initializes the JSON file will the converted to AppInventor dictionary. You can also see that the variable periodicElements gets all the periodic elements details. You can access these details by -

100% Working :white_check_mark:
Hope this clears the problem.


Wow thanks @Alpha2020!

Just one more problem, for your blocks here:


Does this block return a list or a dictionary?

1 Like

A dictionary!!


I get it. Thanks!


Also, I want to make a list of periodic elements. Is this possible to do it with this JSON?

1 Like

What would that look like?
How would you handle isotopes, like U235 vs U238 ?

@Gordon_Lu I am unable to extract the element 'names' from the json. It should be possible but something is wrong with the Web component or with the periodic table json.

I see PTjsonDecode when I look at the file.
All the name data are absent after evaluating the json. @ABG any idea of why?

With respect to an element list; I constructed this ListofElements.txt (1.8 KB) . With the List and a ListView,
you can then start extracting the information from 'elements' any way you want ( I have not done this yet). Something like this

where I can use the ListView to select individual elements.

1 Like

The name tag is in each element, just relocated during decoding.
Here is a dictionary based approach ...

Designer PeriodicTable.json (193.6 KB) PeriodicTableElementsJSON.aia (31.6 KB)

1 Like

Thank you @Alpha2020, @ABG and @SteveJG! It works now!

@ABG thanks. :slight_smile:

@Gordon_Lu the completed Solution if you have not already discovered how to do the parsing?

Remove ABGs original Notify in the AfterPicking then possibly replace with some code like the above . Display as many properties of the element as you want.

Thanks for telling me :slightly_smiling_face: I already figured out how to do that.

1 Like

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