https://sparse-dense.blogspot.com/2019/12/another-example-using-json-decoding.html
[This Extension and its doc are available. Please see the bottom of this article.]
JSON format is commonly used when receiving data from Web services, etc. With App Inventor, JsonTextDecode in the web block can convert JSON to list structures. Then, the conversion result can be manipulated by the selectItem and lookUpInPairs of the list block. However, as Evan W Patton (MIT) pointed out in the paper [1], these list processes are generally very complicated. And he also suggested a more readable and compact Extension block to alleviate this.
I independently developed an Extension for JSON decode based on his new block idea. This Extension might be intuitive and easy to understand because it can hierarchically acquire necessary information with the tag names (properties) without using complicated operations on nested lists. The outline is shown in the figure below. (please enlarge and see the figure.)
This Extension takes two arguments. One is JSON data that was converted into list structure. The other is a search instruction list for hierarchically specifying the value of a specific tag (property). In this example, JSON text holds the values of four kinds of sensors as "healthData". In the above figure, the name of the third sensor is specified. Note that in the query list, a number such as "3" indicates the element index of the JSON array structure.
Query List : John, healthData, 3, sensor
Result : Systolic pressure
JSON data used here is a modified version of the health data published in the following document [2]. The following figure shows the part of listing up all four sensors and their values using this Extension. I think that it is written concisely. Operations for complicated list processing are not appeared here.
Collecting values of the four sensors
An example of running this application is shown below. For details, please see the files shown below.
Result of the test program on Android
・JSON Decoding Extension (beta version, FoYoJSON.aix)revised Jan. 19, 2019
References
Within this Extension, the list structure is iteratively processed using the function of YailList [3]. I think that YailList makes somewhat relaxation of complicated data type conversion (casting) in JAVA. This Extension is still in beta. Although some of the JSON structures have been tested, all the structures are not covered, so bugs may be included. However, it is shown below for your reference. It was tested with Nexus 6 (Android 7.1.1). This extension was created using AppyBuilder Code Editor [4].
・JSON Decoding Extension (beta version, FoYoJSON.aix)revised Jan. 19, 2019
・JSON Decoding Extension Document (pdf file) created on Jan.21, 2019
References
[1] JSON Interoperability in MIT App Inventor
https://2018.splashcon.org/event/blocks-2018-papers-json-interoperability-in-mit-app-inventor
[2] http://georgepavlides.info/ehealth-made-simple/
[3] http://3nportal.com/AIBridge/API/com/google/appinventor/components/runtime/util/YailList.html
[4] AppyBuilder Code Editor
http://Editor.AppyBuilder.com
https://2018.splashcon.org/event/blocks-2018-papers-json-interoperability-in-mit-app-inventor
[2] http://georgepavlides.info/ehealth-made-simple/
[3] http://3nportal.com/AIBridge/API/com/google/appinventor/components/runtime/util/YailList.html
[4] AppyBuilder Code Editor
http://Editor.AppyBuilder.com
thanks for this extension.
返信削除Thank you very much. I'm glad that this extension and its documentation will be useful to you.
返信削除
返信削除Hi there everyone, I have come across almost all the web development sites. However, your website is far better than other in form of content, tools and easiness of using website. Since I am a developer, I am always looking forward to make people aware of web development tools. I can help you people out by introducing you to range of json tools. Here is the link jsononline
Thank you for your interest in my JSON decode extension and for introducing it to many people.
削除Thank you for your nice comments. This encourages me.
返信削除