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.
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
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 bytesThese 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
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.
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