Overview
This Kodular extension is designed to simplify JSON parsing within your Kodular projects. It provides a set of blocks that enable you to easily work with JSON data.
Features
- Parse JSON strings into Kodular variables.
- Access JSON values by key.
- Traverse JSON arrays and objects with ease.
Usage
Parsing JSON
To parse a JSON string, use the ParseJSON block:
JSON Parser Extension
ParseJSON [JSONString]
JSONStringshould contain the JSON data as a string.
Accessing JSON Values
Once you have parsed the JSON, you can access its values using the GetIntegerValue block:
JSON Parser Extension
GetIntegerValue [attributeName] and store in [destinationVariable]
attributeNameis the key of the JSON value you want to retrieve.destinationVariableis where the retrieved value will be stored.
JSON Parser Extension
GetStringValue [attributeName] and store in [destinationVariable]
attributeNameis the key of the JSON value you want to retrieve.destinationVariableis where the retrieved value will be stored.
JSON Parser Extension
GetDoubleValue [attributeName] and store in [destinationVariable]
attributeNameis the key of the JSON value you want to retrieve.destinationVariableis where the retrieved value will be stored.
JSON Parser Extension
OpenJSONObject [JSONString]
JSONStringis the key of the JSON object you want to traverse.
JSON Parser Extension
OpenJSONArray [JSONString]
JSONStringis the key of the JSON array you want to traverse.
JSON Parser Extension
OpenObjectInArrayByIndex [index]
indexis the index of the JSON object you want to traverse.
JSON Parser Extension
OpenArrayInArrayByIndex [index]
indexis the index of the JSON array you want to traverse.
Example
Hereโs a simple example of parsing JSON and accessing its values:
When Screen1.Initialize
JSON Parser Extension
ParseJSON "{\"name\":\"John\",\"age\":30,\"height\":\"1.78\"}"
JSON Parser Extension
GetStringValue "name" and store in global Name
JSON Parser Extension
GetIntegerValue "age" and store in global Age
JSON Parser Extension
GetDoubleValue "height" and store in global Height
In this example, we parse a JSON string, access its values by key, and store them in global variables for later use.
