JSON Create String

Target Category: Arduino, Delfino, F280x, F281X, Generic MCU, Linux AMD64 and Raspberry Pi, Piccolo, STM32

Target Sub-Category: IoT

Blocks Sub-Category: Extensions > IoT

Inputs:

      enable: Initiates string creation at the specified interval.

      keyx/valuex: Indicates the number of key and value pairs.

Output:

      str: JSON string.

Description: The JSON Create String block provides an encoding format for translating data into text strings that can be sent and received over the internet.

JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. JSON Create String is used in conjunction with the MQTT blocks to create JSON-formatted text. By using MQTT to send JSON-formatted text to  mqttbroker.altairsmartcore.com, you can take advantage of Altair IoT Studio’s ability to trigger actions and activate rules that look at the data within the JSON data packet. Output from the JSON Create String block is in the following format:

{“protocol”: “v2”, “checksum”: “”, “device”: “devicename@username.username”, “at”: “now”,“data”: {“Key”: Value}}

A screenshot of a computer error

Description automatically generated 

JSON Syntax Check: Validates the format of the JSON text string.

Key/Value Pairs: Indicates the number of key/value input pin pairs on the JSON block. When you exit the dialog, the input pins on the block are updated accordingly. You cannot use the Add Connector and Remove Connector commands on JSON blocks.

Packet Byte Size: Specifies the maximum buffer size of the data string. Larger strings are truncated to the maximum buffer size.

Examples

See Examples > Blocks > Extensions > IoT > JSON.