日本語 English

SimpleJSON Library (JSON Parsing Library)

What Is JSON?

JSON (JavaScript Object Notation) is a lightweight text-based data format (notation)
It is used to exchange data between various languages such as JavaScript and Python

Overview

The SimpleJSON library is a JSON parsing library created for OMRON NX/NJ series PLCs.
It converts JSON data received via MQTT or REST API communication into Dictionary form so Values can easily be obtained by specifying Keys.
It can be used for integration with AWS IoT Core and various cloud services.

When JSON Is Used on PLCs

JSON is the most commonly used data format in MQTT and REST API communication.
It is used for data integration with AWS IoT Core, Azure IoT Hub, Node-RED, Python applications and more.

Basic JSON example


Data that can be used as Values
StringsCharacters (UTF-8) enclosed in " (double quotes)
NumbersInteger, negative and decimal values and exponential notation (hexadecimal notation and leading zeros are not allowed)
Booleantrue、false
ObjectCharacters enclosed in {}
ArrayCharacters enclosed in []

Specifications of This SimpleJSON Library

Capacity limits
Bytes of JSON that can be handled65535
Number of Keys100
Bytes per Key50 bytes
(including all nested objects *1)
Bytes per Value1986 byte

When the Value is an object, it is nested
Everything other than objects is stored as a string

Value contents
StringStored including " (double quotes)
ValueStored as a string
ArraysEverything from "[" to "]" is stored as a string

Nested objects

When there is an object inside an object, Keys are joined with . (dot)

Conversion examples

Keys and Values when JSON is converted to a Dictionary

JSON

Dictionary
KeyValue
name"taro"
age29
image.visibletrue
image.Title"View from 15th Floor"
image.Thumbnail.Url"http://www.example.com"
image.Thumbnail.Height125
image.Thumbnail.Width100
image.IDs[116,943, 234, 38793]

Functions included in the library

The namespace is "SimpleJSON"

  • Deserialize: converts JSON to a Dictionary
  • GetAryData: extracts elements from a JSON array
  • CharSearch: searches a byte array for a character
  • Get: gets a Value by specifying a Dictionary Key

Example

Usage is explained in the SimpleJSON library usage example

FAQ

Does it support arrays?

Yes. The entire array is held as a string.

Does it support nested objects?

Yes. Keys are managed dot-separated.

Can it be used with AWS MQTT?

Yes. It is suited to parsing JSON data received via MQTT.

Library features

  • Convert JSON to a Dictionary
  • Supports nested objects
  • Get Values by Key
  • Supports Sysmac Studio
  • Can be used to parse MQTT communication data
  • Free of charge

Download

Comments