A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://arduinojson.org/v6/api/config/decode_unicode/ below:

ARDUINOJSON_DECODE_UNICODE | ArduinoJson 6

ArduinoJson can decode Unicode escape sequences (\uXXXX) in JSON documents, but you can disable this feature to reduce the library’s size.

ArduinoJson doesn’t handle NUL correctly: in your input contains \u0000, the string will be truncated.

Description

When ARDUINOJSON_DECODE_UNICODE is set to 1, deserializeJson() converts the Unicode escape sequences to UTF-8 characters.

When ARDUINOJSON_DECODE_UNICODE is set to 0, deserializeJson() returns NotSupported when the input contains a Unicode escape sequence.

The default value is 1.

Only 0 and 1 are valid. Any other value (like false or true) will produce a compilation error.

The default value used to be 0. It changed to 1 in ArduinoJson 6.16

Impact on code size

This feature increases the library’s size; that’s why it used to be disabled by default. The size increase depends on the microcontroller’s architecture, as you can see in the table below.

Architecture Code size Boards (non exhaustive) ARM Cortex-M0 236 bytes ARM Cortex-M3 256 bytes ARM Cortex-M4 640 bytes ARM Cortex-M7 576 bytes AVR 334 bytes megaAVR 330 bytes ESP32 284 bytes ESP8266 304 bytes

These results depend on the compiler version.

How to disable support for Unicode characters in ArduinoJson?

If your input doesn’t contain any Unicode escape sequence, you remove this feature to reduce the library’s size. To do so, simply define ARDUINOJSON_DECODE_UNICODE to 0 before including ArduinoJson.h.

#define ARDUINOJSON_DECODE_UNICODE 0
#include <ArduinoJson.h>
Example
StaticJsonDocument<300> doc;

deserializeJson(doc, "{'firstname':'Beno\\u00EEt'}");
    
Serial.println(doc["firstname"].as<const char*>()); // Benoît

👨‍🏫 Try this example online

Several .ino or .cpp files?

Be careful if several compilation units compose your program, i.e., if your project contains several .ino or .cpp files.

You should define the same value of ARDUINOJSON_DECODE_UNICODE in each compilation unit; otherwise, the executable will be much bigger because it will contain two variants of the library.

  1. Home
  2. Version 6
  3. API
  4. Configuration
  5. ARDUINOJSON_DECODE_UNICODE

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4