ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
- JSON deserialization
- Optionally decodes UTF-16 escape sequences to UTF-8
- Optionally stores links to the input buffer (zero-copy)
- Optionally supports comments in the input
- Optionally filters the input to keep only desired values
- Supports single quotes as a string delimiter
- Compatible with NDJSON and JSON Lines
- JSON serialization
- MessagePack serialization
- MessagePack deserialization
- Efficient
- Versatile
- Supports custom allocators (to use external RAM chip, for example)
- Supports Arduino's
String
and STL'sstd::string
- Supports Arduino's
Stream
and STL'sstd::istream
/std::ostream
- Supports Flash strings
- 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
- Header-only library
- Works with virtually any board
- Tested on all major development environments
- Even works with online compilers like wandbox.org
- CMake friendly
- Well designed
- Elegant API
- Thread-safe
- Self-contained (no external dependency)
const
friendlyfor
friendly- TMP friendly
- Handles integer overflows
- Well tested
- Well documented
- Vibrant user community
- Most popular of all Arduino libraries on GitHub and PlatformIO
- Used in hundreds of projects
- Responsive support
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
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
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.