JSONTools Extension



This is a Beta version of my JSON Tools extension for App Inventor, this extension makes it easier to work with JSON and get the information you need out of a JSON String. Many online services have API's which output in JSON format and this extension will enable you to easily decipher the JSON format.

As mentioned this is a beta release as I have been busy lately, I still wanted to release this extension and make it available for people to play around with, however, as a beta release please note that the methods available in this extension are not finalised and may change in future releases.


× To learn more about JSON and the differences between a JSON Object and a JSON Array, check out my article: Understanding JSON and how it works.


Extension Usage

ParseJSON

The first block to start using this extension is the ParseJSON block, this block takes in JSON as a String and internally converts it into an Object. (Images and more documentation coming soon)


Methods

OpenObject

This method sets the current position to the specified object, e.g. If you called OpenObject("Phone"), this would internally open the phone object so that you can retrieve the values inside.

NEW! Updated Documentation 2019

I hope this updated documentation is helpful in understanding how this extension works, this will be updated over time but please bear with me as I am still working through an overuse injury, I want to keep working on this blog but rest is very important for me to keep doing these things in the future :)


Example - Updated for Version 3+ 2019

The following example takes some sample JSON found online which contains fictitious company contacts and locations, you can tap next and previous buttons to browse through the different contacts and the company coordinates are shown in a Google Maps component.

Screenshot of the blocks used in the JSONToolsExample project







Download Here

× Note: this is a BETA version of this extension, the methods in this extension may change in future releases. Be sure to keep regular backups of your apps.
Links restored 😊
Download Version 4 JSONTools extension here: JSONTools.aix
Download the Updated JSONTools Example project here: JSONToolsExample.aia

Previous Builds:
Download Version 3 JSONTools extension here: JSONTools.aix
Download the JSONTools [BETA] extension here: JSONTools.aix

Version History

Version 4

GetStringInArrayByIndex using zero based indexes, this has been fixed to align with App Inventor Standards.

Added null value checking, preventing runtime errors if null values are used, this has been applied to the following methods:
  • OpenJSONObject
  • OpenJSONArray
  • OpenSubJSONArray
  • OpenSubJSONObject
  • GetStringValue
  • GetIntValue
  • GetBooleanValue
  • GetIntInArray
  • GetStringInArray
  • GetStringInArrayByIndex
  • OpenObjectInArrayByIndex
  • GetStringInSubJSONObject

Version 3

-Fixed OpenObjectInArrayByIndex to use non-zero indexes inline with App Inventor Standards
-Updated GetStringInSubJSONObject for all object types
-Updated Documentation
-Added GetIntInArray

Version 2

This version includes updated function descriptions, I've also implemented some internal variables to track the current location which will help add more useful functionality to this extension.

-OpenJSONObject
-OpenSubJSONObject
-GetIntValue
-GetBooleanValue
-GetStringInArrayByIndex
-OpenObjectInArrayByIndex
-SetCurrentPositionToRoot

Version 1

Initial release with the following functions;

-ParseJSON
-OpenJSONArray
-OpenSubJSONArray
-GetStringValue
-GetStringInArray
-GetStringInSubJSONArray
-GetStringInSubJSONObject
-GetCurrentArrayLength












Icons made by Madebyoliver from www.flaticon.com is licensed by CC 3.0 BY

Was this helpful?

Yes No

Comments

  1. hey bro,when u update examle.I need this :)

    ReplyDelete
    Replies
    1. Hi Yusuf, I have actually updated both the documentation and the example for this extension, hope it helps :)

      Delete
  2. With this extension would it be possible to integrate firebase .json into the trunkable application?

    ReplyDelete
    Replies
    1. Hi there,

      I'm not very familiar with firebase but if it's a standard json file then yes you can implement it with this extension.

      Delete
  3. how to make a list using json tools?
    Can you give a example blocks?

    ReplyDelete
  4. I've been trying to work this extension with firebase and seems not to work. Do you have any example of it?

    ReplyDelete
  5. How can I create both category and subcategory list viewer using one json file: https://suhanihost.com/projects/jsontest/cat5.json

    ReplyDelete
  6. Please check ur thunkable message

    ReplyDelete
  7. how to get value in json within json

    ReplyDelete
    Replies
    1. In the slides i have in the article, have a look at slide 7 for OpenSubJsonObject, it has an example provided that will help you understand

      Delete
  8. how to get address
    please help me

    {
    "home" : {
    "address1" : {
    "Address" : "\"local1\"",
    "Image1" : "\"https:\\/\\/encrypted-tbn0.gstatic.com\\/images?q=tbn:ANd9GcSSlXzPiTfbKFhEtCDQ4W8T3Nt1ctdFT9h88jqWURLG0lC_SA5K&s\"",
    "Image2" : "\"https:\\/\\/images.pexels.com\\/photos\\/462118\\/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500\"",
    "Name" : "\"naveen1\""
    },
    "address2" : {
    "Address" : "\"local1\"",
    "Image1" : "\"https:\\/\\/encrypted-tbn0.gstatic.com\\/images?q=tbn:ANd9GcSSlXzPiTfbKFhEtCDQ4W8T3Nt1ctdFT9h88jqWURLG0lC_SA5K&s\"",
    "Image2" : "\"https:\\/\\/images.pexels.com\\/photos\\/462118\\/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500\"",
    "Name" : "\"naveen2\""
    }
    }
    }

    ReplyDelete
    Replies
    1. If there are multiple items I would've thought your address1 and address2 items would actually be in an array, but for your current JSON use OpenJsonObject Home, then OpenSubJsonObject Address1/2

      Delete
  9. Hi, the download link is not working, pls fix it

    ReplyDelete
    Replies
    1. While I'm no longer actively supporting this extension, I have updated the links, apologies for the inconvenience.

      Delete
  10. Replies
    1. While I'm no longer actively supporting this extension, I have updated the links, apologies for the inconvenience.

      Delete
  11. Hi pls help me
    Give me the Json tool extension it has been deleted pls pls pls 🙏

    ReplyDelete
    Replies
    1. While I'm no longer actively supporting this extension, I have updated the links, apologies for the inconvenience.

      Delete

Post a Comment

Thunkable Components