Generating/ changing JSON object

Working with complex nested object hierarchies performing multiple updates while using variables that have global application scope gets ugly quickly. Therefore I came up with 2 recursive functions which emulate the “Dictionary” blocks from MIT App Inventor 2 of “Get Property For Key Path” and “Set Property For Key Path”. This version does not have any error handling, so if the path is wrong, the update fails without notifying the programmer (but x.Thunkable blocks are the same). At least they get the job done with a LOT fewer blocks.

Each function requres a separate app level variable for the functions to work correctly. The click event and the DictionaryUsers list are there to illustrate the use and are not required. I’ve only done initial testing. If anyone comes up with improvements, please post for us all to enjoy.

An unfortunate limitation is that although variables are global, function are not. The way I use it is I create a form called Dictionary to hold the variables and keep copies of the functions. When another form need the function, it can be copied from the Dictionary form to the target form. Do NOT copy the variables, just the function you need.

I have also saved the example form as a public project at Thunkable

Happy blocking!

Ted