Skip to main content
  • Products
  • Evaluate our Software
  • Downloads
  • Free Utilities
  • Purchase
  • Support
  • About Us
  • Blog
  • Forum
  • Search
    • Contact Us
    • Forum
    • Knowledge Base
    • Web Shop
    • Newsletter
    • RSS
  •   Jobs
  •   Videos
  •   Blog
  •   Sustainability
  • IoT Toolkit
  • JSON Parser
  • Components

JSON parser
IoT Toolkit

The JSON parser library is part of the IoT toolkit that allows easy integration and handling of the JSON (JavaScript Object Notation) data interchange format in an application.

Contact us
Downloads
Documentation
SEGGER IoT Toolkit
  1. 1.Overview
    1. 1.1.Why SEGGER's JSON Parser?
    2. 1.2.Key features
  2. 2.Easy to use API
  3. 3.Requirements
  4. 4.The SEGGER IoT Toolkit evaluation package
  5. 5.JSON parser samples
    1. 5.1.Parsing JSON data using IOT_JSON_Print.exe

Overview

The JSON parser library is part of the IoT toolkit that allows easy integration and handling of the JSON (JavaScript Object Notation) data interchange format in an application without having to deal with the details of it. This allows you to easily evaluate the data returned by modern IoT REST APIs.

The JSON data interchange format is now widely agreed as the standard data format for modern IoT applications and their REST APIs. While other formats like XML provide a similar way to present data, the JSON format is more lightweight while still providing a (human readable) textual representation that is easy to process.

Why SEGGER's JSON Parser?

SEGGER's JSON parser provides a simple to use API that allows you to parse received JSON data without having to know the details of the format. As the JSON data interchange format is used by most modern REST APIs it is a must have component if you are working with IoT applications.

Parsing the tree like JSON data is achieved without actually building other tree like structures for internal processing. This not only benefits the overall RAM requirement but clever internal processing also avoids code recursion to make the stack space bounded.

Sample applications and demos are available to show how simple it is to parse JSON data and how the parsed data is delivered to your application for further processing.

SEGGER has developed the JSON parser from scratch to keep stack usage as small as possible and memory requirements to a minimum.

Key features

  • Memory efficient and easy to use API
  • Supports parsing JSON data in a space-efficient manner
  • Incremental parsing of JSON data read in chunks
  • Items are returned as events instead of a tree-like structure
  • No recursive calls for nested JSON objects, so stack space is bounded

Easy to use API

Using the JSON parser API, handling a response received with JSON data is done in only a couple of lines of simple code.

static const char _sJSONValue[] = {
  "{                                                   "
  "    \"name\": \"My TV\",                            "
  "    \"resolutions\": [                              "
  "        { \"width\": 1280, \"height\": 720 },       "
  "        { \"width\": 1920, \"height\": 1080 },      "
  "        { \"width\": 3840, \"height\": 2160 }       "
  "    ]                                               "
  "}                                                   "
};

static const IOT_JSON_EVENTS _EventAPI = {
  _BeginObject,
  _EndObject,
  _BeginArray,
  _EndArray,
  _Key,
  _String,
  _Number,
  _Literal
};

void MainTask(void) {
  IOT_JSON_CONTEXT JSON;
  char             acBuf[32];
  //
  IOT_JSON_Init(&JSON, &_EventAPI, &acBuf[0], sizeof(acBuf));
  if (IOT_JSON_Parse(&JSON, _sJSONValue, sizeof(_sJSONValue)-1) == 0) {
    printf("\nParse OK\n");
  } else {
    printf("\nParse FAIL\n");
  }
}

Requirements

The JSON parser itself does not rely on any external components. The shipment includes source code samples and Win32 binaries of the samples showing different examples on how to handle data parsed by the API.

The library requires a small work buffer which size is actually determined by the size of the tokens found in the JSON object to parse. As most tokens only consist of a couple of characters even a small buffer like 32 bytes can already be sufficient.

The SEGGER IoT Toolkit evaluation package

A collection of free Windows executables is available for evaluation purposes to show the functionality of the components of the IoT Toolkit.
You can download the IoT Toolkit evaluation package from the following location: IoT Toolkit evaluation package

JSON parser samples

The following is an excerpt of the samples that can be downloaded with the IoT Toolkit evaluation package in binary form. The shipment also includes the source code to these samples.

Parsing JSON data using IOT_JSON_Print.exe


This executable shows processing of data that would be returned by an IoT REST resource. Today's standard for data retrieved and sent to REST APIs is the JSON data format. The sample allows you to test that your JSON data can actually be parsed by the IoT Toolkit JSON library and be utilized in your product.

The sample reads a JSON data content from the standard input of your console. The file "JSON_Content.txt" contains JSON example data as it would be returned by a REST API resource accessed with an HTTP client.

To feed the test data to the executable please execute the following command line:

IOT_JSON_Print.exe < JSON_Content.txt
JSON Print Combined

Headquarters

SEGGER Microcontroller GmbH

Ecolab-Allee 5
40789 Monheim am Rhein, Germany
info@segger.com
Tel.: +49-2173-99312-0
Fax: +49-2173-99312-28

Locations

USA: SEGGER Microcontroller Systems LLC

Boston area
101 Suffolk Lane
Gardner, MA 01440, USA
us-east@segger.com
Tel.: +1-978-874-0299
Fax: +1-978-874-0599

Silicon Valley
Milpitas, CA 95035, USA
us-west@segger.com
Tel.: +1-408-767-4068

China: SEGGER Microcontroller China Co., Ltd.

Room 218, Block A, Dahongqiaoguoji
No. 133 Xiulian Road
Minhang District, Shanghai 201199, China
china@segger.com
Tel.: +86-133-619-907-60

ISO 9001 certified

ISO 9001

30+ years of experience

First-class embedded software tools since 1992
  • Imprint
  • Disclaimer
  • Privacy Policy
© 2025 SEGGER - All rights reserved.