| 1 | <p align="center"> |
| 2 | <a href="https://arduinojson.org/"><img alt="ArduinoJson" src="https://arduinojson.org/images/logo.svg" width="200" /></a> |
| 3 | </p> |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | [](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A7.x) |
| 8 | [](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/7.x) |
| 9 | [](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) |
| 10 | [](https://coveralls.io/github/bblanchon/ArduinoJson?branch=7.x) |
| 11 | [](https://github.com/bblanchon/ArduinoJson/stargazers) |
| 12 | [](https://github.com/sponsors/bblanchon) |
| 13 | |
| 14 | ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). |
| 15 | |
| 16 | ## Features |
| 17 | |
| 18 | * [JSON deserialization](https://arduinojson.org/v7/api/json/deserializejson/) |
| 19 | * [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v7/api/config/decode_unicode/) |
| 20 | * [Optionally supports comments in the input](https://arduinojson.org/v7/api/config/enable_comments/) |
| 21 | * [Optionally filters the input to keep only desired values](https://arduinojson.org/v7/api/json/deserializejson/#filtering) |
| 22 | * Supports single quotes as a string delimiter |
| 23 | * Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/) |
| 24 | * [JSON serialization](https://arduinojson.org/v7/api/json/serializejson/) |
| 25 | * [Can write to a buffer or a stream](https://arduinojson.org/v7/api/json/serializejson/) |
| 26 | * [Optionally indents the document (prettified JSON)](https://arduinojson.org/v7/api/json/serializejsonpretty/) |
| 27 | * [MessagePack serialization](https://arduinojson.org/v7/api/msgpack/serializemsgpack/) |
| 28 | * [MessagePack deserialization](https://arduinojson.org/v7/api/msgpack/deserializemsgpack/) |
| 29 | * Efficient |
| 30 | * [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) |
| 31 | * [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) |
| 32 | * [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/) |
| 33 | * [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/) |
| 34 | * Versatile |
| 35 | * Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v7/how-to/use-external-ram-on-esp32/) |
| 36 | * Supports [`String`](https://arduinojson.org/v7/api/config/enable_arduino_string/), [`std::string`](https://arduinojson.org/v7/api/config/enable_std_string/), and [`std::string_view`](https://arduinojson.org/v7/api/config/enable_string_view/) |
| 37 | * Supports [`Stream`](https://arduinojson.org/v7/api/config/enable_arduino_stream/) and [`std::istream`/`std::ostream`](https://arduinojson.org/v7/api/config/enable_std_stream/) |
| 38 | * Supports [Flash strings](https://arduinojson.org/v7/api/config/enable_progmem/) |
| 39 | * Supports [custom readers](https://arduinojson.org/v7/api/json/deserializejson/#custom-reader) and [custom writers](https://arduinojson.org/v7/api/json/serializejson/#custom-writer) |
| 40 | * Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/) |
| 41 | * Portable |
| 42 | * Usable on any C++ project (not limited to Arduino) |
| 43 | * Compatible with C++11, C++14 and C++17 |
| 44 | * Support for C++98/C++03 available on [ArduinoJson 6.20.x](https://github.com/bblanchon/ArduinoJson/tree/6.20.x) |
| 45 | * Zero warnings with `-Wall -Wextra -pedantic` and `/W4` |
| 46 | * [Header-only library](https://en.wikipedia.org/wiki/Header-only) |
| 47 | * Works with virtually any board |
| 48 | * Arduino boards: [Uno](https://amzn.to/38aL2ik), [Due](https://amzn.to/36YkWi2), [Micro](https://amzn.to/35WkdwG), [Nano](https://amzn.to/2QTvwRX), [Mega](https://amzn.to/36XWhuf), [Yun](https://amzn.to/30odURc), [Leonardo](https://amzn.to/36XWjlR)... |
| 49 | * Espressif chips: [ESP8266](https://amzn.to/36YluV8), [ESP32](https://amzn.to/2G4pRCB) |
| 50 | * Lolin (WeMos) boards: [D1 mini](https://amzn.to/2QUpz7q), [D1 Mini Pro](https://amzn.to/36UsGSs)... |
| 51 | * Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj) |
| 52 | * Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)... |
| 53 | * Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)... |
| 54 | * Soft cores: [Nios II](https://en.wikipedia.org/wiki/Nios_II)... |
| 55 | * Tested on all major development environments |
| 56 | * [Arduino IDE](https://www.arduino.cc/en/Main/Software) |
| 57 | * [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/) |
| 58 | * [Atollic TrueSTUDIO](https://atollic.com/truestudio/) |
| 59 | * [Energia](http://energia.nu/) |
| 60 | * [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/) |
| 61 | * [Keil uVision](http://www.keil.com/) |
| 62 | * [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide) |
| 63 | * [Particle](https://www.particle.io/) |
| 64 | * [PlatformIO](http://platformio.org/) |
| 65 | * [Sloeber plugin for Eclipse](https://eclipse.baeyens.it/) |
| 66 | * [Visual Micro](http://www.visualmicro.com/) |
| 67 | * [Visual Studio](https://www.visualstudio.com/) |
| 68 | * [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN) |
| 69 | * [CMake friendly](https://arduinojson.org/v7/how-to/use-arduinojson-with-cmake/) |
| 70 | * Well designed |
| 71 | * [Elegant API](http://arduinojson.org/v7/example/) |
| 72 | * [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety) |
| 73 | * Self-contained (no external dependency) |
| 74 | * `const` friendly |
| 75 | * [`for` friendly](https://arduinojson.org/v7/api/jsonobject/begin_end/) |
| 76 | * [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming) |
| 77 | * Handles [integer overflows](https://arduinojson.org/v7/api/jsonvariant/as/#integer-overflows) |
| 78 | * Well tested |
| 79 | * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=7.x) |
| 80 | * Continuously tested on |
| 81 | * [Visual Studio 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/7.x) |
| 82 | * [GCC 4.8, 5, 6, 7, 8, 9, 10, 11, 12](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) |
| 83 | * [Clang 7 to 19](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) |
| 84 | * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) |
| 85 | * Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/) |
| 86 | * Well documented |
| 87 | * [Tutorials](https://arduinojson.org/v7/doc/deserialization/) |
| 88 | * [Examples](https://arduinojson.org/v7/example/) |
| 89 | * [How-tos](https://arduinojson.org/v7/example/) |
| 90 | * [FAQ](https://arduinojson.org/v7/faq/) |
| 91 | * [Troubleshooter](https://arduinojson.org/v7/troubleshooter/) |
| 92 | * [Book](https://arduinojson.org/book/) |
| 93 | * [Changelog](CHANGELOG.md) |
| 94 | * Vibrant user community |
| 95 | * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) |
| 96 | * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) |
| 97 | * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed) |
| 98 | |
| 99 | ## Quickstart |
| 100 | |
| 101 | ### Deserialization |
| 102 | |
| 103 | Here is a program that parses a JSON document with ArduinoJson. |
| 104 | |
| 105 | ```c++ |
| 106 | const char* json = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; |
| 107 | |
| 108 | JsonDocument doc; |
| 109 | deserializeJson(doc, json); |
| 110 | |
| 111 | const char* sensor = doc["sensor"]; |
| 112 | long time = doc["time"]; |
| 113 | double latitude = doc["data"][0]; |
| 114 | double longitude = doc["data"][1]; |
| 115 | ``` |
| 116 | |
| 117 | See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/deserialization/) |
| 118 | |
| 119 | ### Serialization |
| 120 | |
| 121 | Here is a program that generates a JSON document with ArduinoJson: |
| 122 | |
| 123 | ```c++ |
| 124 | JsonDocument doc; |
| 125 | |
| 126 | doc["sensor"] = "gps"; |
| 127 | doc["time"] = 1351824120; |
| 128 | doc["data"][0] = 48.756080; |
| 129 | doc["data"][1] = 2.302038; |
| 130 | |
| 131 | serializeJson(doc, Serial); |
| 132 | // This prints: |
| 133 | // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} |
| 134 | ``` |
| 135 | |
| 136 | See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/serialization/) |
| 137 | |
| 138 | ## Sponsors |
| 139 | |
| 140 | ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it! |
| 141 | |
| 142 | <p> |
| 143 | <a href="https://github.com/1technophile" rel="sponsored"> |
| 144 | <img alt="1technophile" src="https://avatars.githubusercontent.com/u/12672732?s=40&v=4"> |
| 145 | </a> |
| 146 | <a href="https://github.com/LArkema" rel="sponsored"> |
| 147 | <img alt="LArkema" src="https://avatars.githubusercontent.com/u/38381313?s=40&v=4"> |
| 148 | </a> |
| 149 | </p> |
| 150 | |
| 151 | If you run a commercial project that embeds ArduinoJson, think about [sponsoring the library's development](https://github.com/sponsors/bblanchon): it ensures the code that your products rely on stays actively maintained. It can also give your project some exposure to the makers' community. |
| 152 | |
| 153 | If you are an individual user and want to support the development (or give a sign of appreciation), consider purchasing the book [Mastering ArduinoJson](https://arduinojson.org/book/) ❤, or simply [cast a star](https://github.com/bblanchon/ArduinoJson/stargazers) ⭐. |