Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
README.md@0:18ba3960b5dd, 2021-03-19 (annotated)
- Committer:
- khaiminhvn
- Date:
- Fri Mar 19 19:30:50 2021 +0000
- Revision:
- 0:18ba3960b5dd
removed extras
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| khaiminhvn | 0:18ba3960b5dd | 1 |  |
| khaiminhvn | 0:18ba3960b5dd | 2 | |
| khaiminhvn | 0:18ba3960b5dd | 3 | --- |
| khaiminhvn | 0:18ba3960b5dd | 4 | |
| khaiminhvn | 0:18ba3960b5dd | 5 | [](https://www.ardu-badge.com/ArduinoJson/6.17.2) |
| khaiminhvn | 0:18ba3960b5dd | 6 | [](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x) |
| khaiminhvn | 0:18ba3960b5dd | 7 | [](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) |
| khaiminhvn | 0:18ba3960b5dd | 8 | [](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) |
| khaiminhvn | 0:18ba3960b5dd | 9 | [](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) |
| khaiminhvn | 0:18ba3960b5dd | 10 | [](https://github.com/bblanchon/ArduinoJson/stargazers) |
| khaiminhvn | 0:18ba3960b5dd | 11 | |
| khaiminhvn | 0:18ba3960b5dd | 12 | ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). |
| khaiminhvn | 0:18ba3960b5dd | 13 | |
| khaiminhvn | 0:18ba3960b5dd | 14 | ## Features |
| khaiminhvn | 0:18ba3960b5dd | 15 | |
| khaiminhvn | 0:18ba3960b5dd | 16 | * [JSON deserialization](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 17 | * [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v6/api/config/decode_unicode/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 18 | * [Optionally stores links to the input buffer (zero-copy)](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 19 | * [Optionally supports comments in the input](https://arduinojson.org/v6/api/config/enable_comments/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 20 | * [Optionally filters the input to keep only desired values](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#filtering) |
| khaiminhvn | 0:18ba3960b5dd | 21 | * Supports single quotes as a string delimiter |
| khaiminhvn | 0:18ba3960b5dd | 22 | * Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/) |
| khaiminhvn | 0:18ba3960b5dd | 23 | * [JSON serialization](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 24 | * [Can write to a buffer or a stream](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 25 | * [Optionally indents the document (prettified JSON)](https://arduinojson.org/v6/api/json/serializejsonpretty/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 26 | * [MessagePack serialization](https://arduinojson.org/v6/api/msgpack/serializemsgpack/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 27 | * [MessagePack deserialization](https://arduinojson.org/v6/api/msgpack/deserializemsgpack/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 28 | * Efficient |
| khaiminhvn | 0:18ba3960b5dd | 29 | * [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 30 | * [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 31 | * [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 32 | * [Fixed memory allocation, no heap fragmentation](https://arduinojson.org/v6/api/jsondocument/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 33 | * [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 34 | * Deduplicates strings |
| khaiminhvn | 0:18ba3960b5dd | 35 | * Versatile |
| khaiminhvn | 0:18ba3960b5dd | 36 | * [Supports custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 37 | * 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) |
| khaiminhvn | 0:18ba3960b5dd | 38 | * 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) |
| khaiminhvn | 0:18ba3960b5dd | 39 | * [Supports Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 40 | * Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme#custom-writer) |
| khaiminhvn | 0:18ba3960b5dd | 41 | * Portable |
| khaiminhvn | 0:18ba3960b5dd | 42 | * Usable on any C++ project (not limited to Arduino) |
| khaiminhvn | 0:18ba3960b5dd | 43 | * Compatible with C++98 |
| khaiminhvn | 0:18ba3960b5dd | 44 | * Zero warnings with `-Wall -Wextra -pedantic` and `/W4` |
| khaiminhvn | 0:18ba3960b5dd | 45 | * [Header-only library](https://en.wikipedia.org/wiki/Header-only) |
| khaiminhvn | 0:18ba3960b5dd | 46 | * Works with virtually any board |
| khaiminhvn | 0:18ba3960b5dd | 47 | * 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)... |
| khaiminhvn | 0:18ba3960b5dd | 48 | * Espressif chips: [ESP8266](https://amzn.to/36YluV8), [ESP32](https://amzn.to/2G4pRCB) |
| khaiminhvn | 0:18ba3960b5dd | 49 | * Lolin (WeMos) boards: [D1 mini](https://amzn.to/2QUpz7q), [D1 Mini Pro](https://amzn.to/36UsGSs)... |
| khaiminhvn | 0:18ba3960b5dd | 50 | * Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj) |
| khaiminhvn | 0:18ba3960b5dd | 51 | * Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)... |
| khaiminhvn | 0:18ba3960b5dd | 52 | * Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)... |
| khaiminhvn | 0:18ba3960b5dd | 53 | * Tested on all major development environments |
| khaiminhvn | 0:18ba3960b5dd | 54 | * [Arduino IDE](https://www.arduino.cc/en/Main/Software) |
| khaiminhvn | 0:18ba3960b5dd | 55 | * [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/) |
| khaiminhvn | 0:18ba3960b5dd | 56 | * [Atollic TrueSTUDIO](https://atollic.com/truestudio/) |
| khaiminhvn | 0:18ba3960b5dd | 57 | * [Energia](http://energia.nu/) |
| khaiminhvn | 0:18ba3960b5dd | 58 | * [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/) |
| khaiminhvn | 0:18ba3960b5dd | 59 | * [Keil uVision](http://www.keil.com/) |
| khaiminhvn | 0:18ba3960b5dd | 60 | * [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide) |
| khaiminhvn | 0:18ba3960b5dd | 61 | * [Particle](https://www.particle.io/) |
| khaiminhvn | 0:18ba3960b5dd | 62 | * [PlatformIO](http://platformio.org/) |
| khaiminhvn | 0:18ba3960b5dd | 63 | * [Sloeber plugin for Eclipse](https://eclipse.baeyens.it/) |
| khaiminhvn | 0:18ba3960b5dd | 64 | * [Visual Micro](http://www.visualmicro.com/) |
| khaiminhvn | 0:18ba3960b5dd | 65 | * [Visual Studio](https://www.visualstudio.com/) |
| khaiminhvn | 0:18ba3960b5dd | 66 | * [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN) |
| khaiminhvn | 0:18ba3960b5dd | 67 | * [CMake friendly](https://arduinojson.org/v6/how-to/use-arduinojson-with-cmake/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 68 | * Well designed |
| khaiminhvn | 0:18ba3960b5dd | 69 | * [Elegant API](http://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 70 | * [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety) |
| khaiminhvn | 0:18ba3960b5dd | 71 | * Self-contained (no external dependency) |
| khaiminhvn | 0:18ba3960b5dd | 72 | * `const` friendly |
| khaiminhvn | 0:18ba3960b5dd | 73 | * [`for` friendly](https://arduinojson.org/v6/api/jsonobject/begin_end/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 74 | * [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming) |
| khaiminhvn | 0:18ba3960b5dd | 75 | * Handles [integer overflows](https://arduinojson.org/v6/api/jsonvariant/as/?utm_source=github&utm_medium=readme#integer-overflows) |
| khaiminhvn | 0:18ba3960b5dd | 76 | * Well tested |
| khaiminhvn | 0:18ba3960b5dd | 77 | * [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) |
| khaiminhvn | 0:18ba3960b5dd | 78 | * Continuously tested on |
| khaiminhvn | 0:18ba3960b5dd | 79 | * [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) |
| khaiminhvn | 0:18ba3960b5dd | 80 | * [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) |
| khaiminhvn | 0:18ba3960b5dd | 81 | * [Clang 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22) |
| khaiminhvn | 0:18ba3960b5dd | 82 | * [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) |
| khaiminhvn | 0:18ba3960b5dd | 83 | * Well documented |
| khaiminhvn | 0:18ba3960b5dd | 84 | * [Tutorials](https://arduinojson.org/v6/doc/deserialization/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 85 | * [Examples](https://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 86 | * [How-tos](https://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 87 | * [FAQ](https://arduinojson.org/v6/faq/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 88 | * [Book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 89 | * [Changelog](changelog.md) |
| khaiminhvn | 0:18ba3960b5dd | 90 | * Vibrant user community |
| khaiminhvn | 0:18ba3960b5dd | 91 | * Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories) and [PlatformIO](https://platformio.org/lib/search) |
| khaiminhvn | 0:18ba3960b5dd | 92 | * [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson) |
| khaiminhvn | 0:18ba3960b5dd | 93 | * [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed) |
| khaiminhvn | 0:18ba3960b5dd | 94 | |
| khaiminhvn | 0:18ba3960b5dd | 95 | ## Quickstart |
| khaiminhvn | 0:18ba3960b5dd | 96 | |
| khaiminhvn | 0:18ba3960b5dd | 97 | ### Deserialization |
| khaiminhvn | 0:18ba3960b5dd | 98 | |
| khaiminhvn | 0:18ba3960b5dd | 99 | Here is a program that parses a JSON document with ArduinoJson. |
| khaiminhvn | 0:18ba3960b5dd | 100 | |
| khaiminhvn | 0:18ba3960b5dd | 101 | ```c++ |
| khaiminhvn | 0:18ba3960b5dd | 102 | char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; |
| khaiminhvn | 0:18ba3960b5dd | 103 | |
| khaiminhvn | 0:18ba3960b5dd | 104 | DynamicJsonDocument doc(1024); |
| khaiminhvn | 0:18ba3960b5dd | 105 | deserializeJson(doc, json); |
| khaiminhvn | 0:18ba3960b5dd | 106 | |
| khaiminhvn | 0:18ba3960b5dd | 107 | const char* sensor = doc["sensor"]; |
| khaiminhvn | 0:18ba3960b5dd | 108 | long time = doc["time"]; |
| khaiminhvn | 0:18ba3960b5dd | 109 | double latitude = doc["data"][0]; |
| khaiminhvn | 0:18ba3960b5dd | 110 | double longitude = doc["data"][1]; |
| khaiminhvn | 0:18ba3960b5dd | 111 | ``` |
| khaiminhvn | 0:18ba3960b5dd | 112 | |
| khaiminhvn | 0:18ba3960b5dd | 113 | See the [tutorial on arduinojson.org](https://arduinojson.org/doc/decoding/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 114 | |
| khaiminhvn | 0:18ba3960b5dd | 115 | ### Serialization |
| khaiminhvn | 0:18ba3960b5dd | 116 | |
| khaiminhvn | 0:18ba3960b5dd | 117 | Here is a program that generates a JSON document with ArduinoJson: |
| khaiminhvn | 0:18ba3960b5dd | 118 | |
| khaiminhvn | 0:18ba3960b5dd | 119 | ```c++ |
| khaiminhvn | 0:18ba3960b5dd | 120 | DynamicJsonDocument doc(1024); |
| khaiminhvn | 0:18ba3960b5dd | 121 | |
| khaiminhvn | 0:18ba3960b5dd | 122 | doc["sensor"] = "gps"; |
| khaiminhvn | 0:18ba3960b5dd | 123 | doc["time"] = 1351824120; |
| khaiminhvn | 0:18ba3960b5dd | 124 | doc["data"][0] = 48.756080; |
| khaiminhvn | 0:18ba3960b5dd | 125 | doc["data"][1] = 2.302038; |
| khaiminhvn | 0:18ba3960b5dd | 126 | |
| khaiminhvn | 0:18ba3960b5dd | 127 | serializeJson(doc, Serial); |
| khaiminhvn | 0:18ba3960b5dd | 128 | // This prints: |
| khaiminhvn | 0:18ba3960b5dd | 129 | // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} |
| khaiminhvn | 0:18ba3960b5dd | 130 | ``` |
| khaiminhvn | 0:18ba3960b5dd | 131 | |
| khaiminhvn | 0:18ba3960b5dd | 132 | See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme) |
| khaiminhvn | 0:18ba3960b5dd | 133 | |
| khaiminhvn | 0:18ba3960b5dd | 134 | ## Support the project |
| khaiminhvn | 0:18ba3960b5dd | 135 | |
| khaiminhvn | 0:18ba3960b5dd | 136 | Do you like this library? Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)! |
| khaiminhvn | 0:18ba3960b5dd | 137 | |
| khaiminhvn | 0:18ba3960b5dd | 138 | What? You don't like it but you *love* it? |
| khaiminhvn | 0:18ba3960b5dd | 139 | We don't take donations anymore, but [we sell a book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme), so you can help and learn at the same time. |