ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
Features
-
Supports single quotes as a string delimiter
Compatible with NDJSON and JSON Lines
Efficient
Versatile
Supports custom allocators (to use external RAM chip, for example)
Supports Arduino’s ``String` <https://arduinojson.org/v6/api/config/enable_arduino_string/>`_ and STL’s ``std::string` <https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme>`_
Supports Arduino’s
Stream
and STL’s ``std::istream`/std::ostream
<https://arduinojson.org/v6/api/config/enable_std_stream/?utm_source=github&utm_medium=readme>`_Supports custom readers and custom writers
Portable
Usable on any C++ project (not limited to Arduino)
Compatible with C++98
Zero warnings with
-Wall -Wextra -pedantic
and/W4
Works with virtually any board
Tested on all major development environments
Well designed
Self-contained (no external dependency)
const
friendly``for` friendly <https://arduinojson.org/v6/api/jsonobject/begin_end/?utm_source=github&utm_medium=readme>`_
Handles integer overflows
Well tested
Well documented
Vibrant user community
Most popular of all Arduino libraries on GitHub and PlatformIO
Quickstart
Deserialization
Here is a program that parses a JSON document with ArduinoJson.
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
DynamicJsonDocument doc(1024);
deserializeJson(doc, json);
const char* sensor = doc["sensor"];
long time = doc["time"];
double latitude = doc["data"][0];
double longitude = doc["data"][1];
See the tutorial on arduinojson.org
Serialization
Here is a program that generates a JSON document with ArduinoJson:
DynamicJsonDocument doc(1024);
doc["sensor"] = "gps";
doc["time"] = 1351824120;
doc["data"][0] = 48.756080;
doc["data"][1] = 2.302038;
serializeJson(doc, Serial);
// This prints:
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
See the tutorial on arduinojson.org
Support the project
Do you like this library? Please star this project on GitHub!
What? You don’t like it but you love it?
We don’t take donations anymore, but we sell a book, so you can help and learn at the same time.