Compare commits

...

58 Commits

Author SHA1 Message Date
ddfe7d8b91 Set version to 6.14.0 2020-01-16 20:48:03 +01:00
4a657ca87f Update the features section of the README page 2020-01-16 20:46:25 +01:00
1e3d478998 Improved speed of serializeXxx() when writing to a String 2020-01-14 14:50:44 +01:00
3aebef6d0a Fixed value returned by serializeXxx() when writing to a String 2020-01-14 11:22:44 +01:00
25879466da Fixed variant.is<nullptr_t>() 2020-01-13 20:47:43 +01:00
27ec1afb7a Configure the "lock-threads" app 2020-01-13 18:23:30 +01:00
06a0d1a872 Added measureJson, measureJsonPretty, and measureMsgPack to keywords 2020-01-13 18:20:05 +01:00
04fe7e1a27 Added ARDUINOJSON_ENABLE_COMMENTS to enable support for comments 2020-01-13 18:16:02 +01:00
f9cfea244a Updated copyright notice 2020-01-09 15:48:38 +01:00
5ec062cc71 Reduced Unicode conversion code size (-122 bytes on AVR) 2020-01-09 15:39:45 +01:00
91b808381e Improved decoding of UTF-16 surrogate pairs (closes #1157) 2020-01-08 09:55:43 +01:00
8550418875 Auto enable std::string and stream on modern compilers (closes #1156) 2020-01-04 15:05:20 +01:00
00c391320c Added support for CMake's unity builds 2019-12-24 16:42:34 +01:00
9723682d20 AppVeyor: added Visual Studio 2019 2019-12-24 16:10:11 +01:00
8bf6f6e09f Added support uint8_t for serializeMsgPack() (closes #1142) 2019-12-13 14:15:30 +01:00
062c1c13b5 Added BasicJsonDocument::shrinkToFit() 2019-11-07 15:40:20 +01:00
1b8107094f Set version to 6.13.0 2019-11-01 10:32:45 +01:00
8721ac88b1 Reorganized writer classes 2019-10-31 19:27:23 +01:00
6da6f921cd Fixed dangling reference in MemberProxy and ElementProxy (fixes #1120) 2019-10-30 19:09:21 +01:00
ef63757b1a Fixed deserializer that stopped reading at the first 0xFF (closes #1118) 2019-10-29 14:17:11 +01:00
3a169df0a5 Added support for custom reader classes 2019-10-25 11:39:04 +02:00
d4f819f1f0 Added detection of Atmel AVR8/GNU C Compiler (fixes #1112) 2019-10-18 22:10:35 +02:00
16fe3c0acc Improved deserializeMsgPack() speed by reading several bytes at once 2019-10-14 12:02:26 +02:00
fd8f4eb3a6 Moved msgpack.org.md to github.com/bblanchon/ArduinoJson-msgpack.org 2019-10-11 09:07:25 +02:00
b261eca865 esp-idf make system 2019-10-07 09:00:31 +02:00
a37480eec9 Fixed deserializeJson() when input contains duplicate keys (fixes #1095) 2019-09-27 10:07:29 +02:00
713aaa3d68 Added msgpack.org.md
https://github.com/msgpack/website/blob/master/README.md#how-to-list-up-your-project-on-msgpackorg
2019-09-26 09:52:50 +02:00
7d1d0c4e67 Added conversion from JsonArray/JsonObject to bool 2019-09-24 09:38:00 +02:00
4ad05dbaef Replaced GitHub stars badge 2019-09-19 09:28:57 +02:00
38371aae62 Added OSS-Fuzz badge 2019-09-19 09:28:49 +02:00
498a2e4c1e Added support for custom writer classes (closes #1088) 2019-09-13 14:10:21 +02:00
2078871f36 Added missing #include <ArduinoJson/Namespace.hpp> 2019-09-13 12:09:07 +02:00
140525b7a0 Fix deployment scripts 2019-09-05 09:36:18 +02:00
1a81d46a97 Set version to 6.12.0 2019-09-05 09:31:06 +02:00
4c4c4688a9 Fix src/ path in Makefile 2019-09-04 09:13:09 +02:00
b47ac27ac6 Moved ancillary files to extras/ (fixes #1011) 2019-09-03 15:11:05 +02:00
ed18e77655 Changed as<bool>() to return true for any non-null value (closes #1005) 2019-08-29 08:56:34 +02:00
fcbec6eb6d Use absolute instead of relative includes (fixes #1072) 2019-08-26 11:57:57 +02:00
f5c25823bc Set version to 6.11.5 2019-08-23 08:40:10 +02:00
f00dfd7bfe Added fallbacks strlen_P, strncmp_P, strcmp_P and memcpy_P (fixes #1073) 2019-08-21 15:25:54 +02:00
dcca4214f5 Set version to 6.11.4 2019-08-12 15:10:56 +02:00
1e9cc285bb Added support for basic_string<char, traits, allocator> (closes #1045) 2019-08-12 14:21:45 +02:00
b9c4a0c5f6 Include Arduino.h if ARDUINO is defined (closes #1071) 2019-08-11 13:04:12 +02:00
0d339300f9 Added tests for Flash strings (closes #1070) 2019-08-11 11:39:21 +02:00
63d7d87080 Fixed example JsonConfigFile.ino for ESP8266 2019-08-10 14:17:23 +02:00
2ee655f9ba Fix clang installation on Travis 2019-08-10 12:22:17 +02:00
61a4195ed4 Added measureJson() to the ArduinoJson namespace (fixes #1069) 2019-08-10 11:15:11 +02:00
a6f029ded0 Set version to 6.11.3 2019-07-22 08:59:54 +02:00
b54de58e6b Fixed comparison of JsonVariant with mixed strings (closes #1051) 2019-07-19 12:15:16 +02:00
795e37278f Added operators == and != for MemberProxy 2019-07-19 10:27:03 +02:00
7ce1039d7c Added operators == and != for MemberProxy 2019-07-19 10:23:06 +02:00
aba42faf69 Added operators == and != for JsonDocument 2019-07-19 10:23:06 +02:00
815326d42e Set version to 6.11.2 2019-07-08 08:44:27 +02:00
7d40a541c9 Fix invalid conversion error on Particle Argon (closes #1035) 2019-07-01 09:07:16 +02:00
2507ee2e56 Fixed assignment of JsonDocument to JsonVariant (issue #1023) 2019-06-25 08:56:14 +02:00
a0a451195b Set version to 6.11.1 2019-06-21 08:49:02 +02:00
ce247a5637 Fixed serialized() not working with Flash strings (fixes #1030) 2019-06-21 08:46:32 +02:00
59f9c9747f Add sponsor button on GitHub 2019-06-04 09:14:37 +02:00
394 changed files with 4160 additions and 2239 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
custom: https://arduinojson.org/book/

7
.github/lock.yml vendored Normal file
View File

@ -0,0 +1,7 @@
# Configuration for Lock Threads - https://github.com/dessant/lock-threads
# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 30
# Comment to post before locking. Set to `false` to disable
lockComment: false

6
.gitignore vendored
View File

@ -6,7 +6,7 @@
/sftp-config.json
.tags
.tags_sorted_by_file
/fuzzing/*_fuzzer
/fuzzing/*_fuzzer.options
/fuzzing/*_fuzzer_seed_corpus.zip
/extras/fuzzing/*_fuzzer
/extras/fuzzing/*_fuzzer.options
/extras/fuzzing/*_fuzzer_seed_corpus.zip
.vs/

View File

@ -84,12 +84,12 @@ matrix:
env: SCRIPT=test _CC=clang-4.0 _CXX=clang++-4.0
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-5.0']
sources: ['ubuntu-toolchain-r-test']
packages: ['clang-5.0']
env: SCRIPT=test _CC=clang-5.0 _CXX=clang++-5.0
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
sources: ['ubuntu-toolchain-r-test']
packages: ['clang-6.0']
env: SCRIPT=test _CC=clang-6.0 _CXX=clang++-6.0
- addons:
@ -121,12 +121,12 @@ matrix:
- env: SCRIPT=platformio BOARD=esp01
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
sources: ['ubuntu-toolchain-r-test']
packages: ['clang-6.0','llvm-6.0']
env: SCRIPT=fuzz CLANG=6.0
cache:
directories:
- "~/.platformio"
- "fuzzing/json_corpus"
- "fuzzing/msgpack_corpus"
script: scripts/travis/$SCRIPT.sh
- "extras/fuzzing/json_corpus"
- "extras/fuzzing/msgpack_corpus"
script: extras/ci/$SCRIPT.sh

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include "src/ArduinoJson.h"

View File

@ -1,6 +1,83 @@
ArduinoJson: change log
=======================
v6.14.0 (2020-01-16)
-------
* Added `BasicJsonDocument::shrinkToFit()`
* Added support of `uint8_t` for `serializeJson()`, `serializeJsonPretty()`, and `serializeMsgPack()` (issue #1142)
* Added `ARDUINOJSON_ENABLE_COMMENTS` to enable support for comments (defaults to 0)
* Auto enable support for `std::string` and `std::stream` on modern compilers (issue #1156)
(No need to define `ARDUINOJSON_ENABLE_STD_STRING` and `ARDUINOJSON_ENABLE_STD_STREAM` anymore)
* Improved decoding of UTF-16 surrogate pairs (PR #1157 by @kaysievers)
(ArduinoJson now produces standard UTF-8 instead of CESU-8)
* Added `measureJson`, `measureJsonPretty`, and `measureMsgPack` to `keywords.txt`
(This file is used for syntax highlighting in the Arduino IDE)
* Fixed `variant.is<nullptr_t>()`
* Fixed value returned by `serializeJson()`, `serializeJsonPretty()`, and `serializeMsgPack()` when writing to a `String`
* Improved speed of `serializeJson()`, `serializeJsonPretty()`, and `serializeMsgPack()` when writing to a `String`
> ### BREAKING CHANGES
>
> #### Comments
>
> Support for comments in input is now optional and disabled by default.
>
> If you need support for comments, you must defined `ARDUINOJSON_ENABLE_COMMENTS` to `1`; otherwise, you'll receive `InvalidInput` errors.
>
> ```c++
> #define ARDUINOJSON_ENABLE_COMMENTS 1
> #include <ArduinoJson.h>
> ```
v6.13.0 (2019-11-01)
-------
* Added support for custom writer/reader classes (issue #1088)
* Added conversion from `JsonArray` and `JsonObject` to `bool`, to be consistent with `JsonVariant`
* Fixed `deserializeJson()` when input contains duplicate keys (issue #1095)
* Improved `deserializeMsgPack()` speed by reading several bytes at once
* Added detection of Atmel AVR8/GNU C Compiler (issue #1112)
* Fixed deserializer that stopped reading at the first `0xFF` (PR #1118 by @mikee47)
* Fixed dangling reference in copies of `MemberProxy` and `ElementProxy` (issue #1120)
v6.12.0 (2019-09-05)
-------
* Use absolute instead of relative includes (issue #1072)
* Changed `JsonVariant::as<bool>()` to return `true` for any non-null value (issue #1005)
* Moved ancillary files to `extras/` (issue #1011)
v6.11.5 (2019-08-23)
-------
* Added fallback implementations of `strlen_P()`, `strncmp_P()`, `strcmp_P()`, and `memcpy_P()` (issue #1073)
v6.11.4 (2019-08-12)
-------
* Added `measureJson()` to the `ArduinoJson` namespace (PR #1069 by @nomis)
* Added support for `basic_string<char, traits, allocator>` (issue #1045)
* Fixed example `JsonConfigFile.ino` for ESP8266
* Include `Arduino.h` if `ARDUINO` is defined (PR #1071 by @nomis)
v6.11.3 (2019-07-22)
-------
* Added operators `==` and `!=` for `JsonDocument`, `ElementProxy`, and `MemberProxy`
* Fixed comparison of `JsonVariant` when one contains a linked string and the other contains an owned string (issue #1051)
v6.11.2 (2019-07-08)
-------
* Fixed assignment of `JsonDocument` to `JsonVariant` (issue #1023)
* Fix invalid conversion error on Particle Argon (issue #1035)
v6.11.1 (2019-06-21)
-------
* Fixed `serialized()` not working with Flash strings (issue #1030)
v6.11.0 (2019-05-26)
-------

View File

@ -1,5 +1,5 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2019
# Copyright Benoit Blanchon 2014-2020
# MIT License
cmake_minimum_required(VERSION 3.0)
@ -17,6 +17,5 @@ if(${COVERAGE})
endif()
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
add_subdirectory(third-party/catch)
add_subdirectory(test)
add_subdirectory(fuzzing)
add_subdirectory(extras/tests)
add_subdirectory(extras/fuzzing)

129
README.md
View File

@ -2,58 +2,88 @@
---
[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.11.0)](https://www.ardu-badge.com/ArduinoJson/6.11.0)
[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.14.0)](https://www.ardu-badge.com/ArduinoJson/6.14.0)
[![Build Status](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
[![Build Status](https://travis-ci.org/bblanchon/ArduinoJson.svg?branch=6.x)](https://travis-ci.org/bblanchon/ArduinoJson)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
[![Coverage Status](https://coveralls.io/repos/github/bblanchon/ArduinoJson/badge.svg?branch=6.x)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
[![Star this project](http://githubbadges.com/star.svg?user=bblanchon&repo=ArduinoJson&style=flat&color=fff&background=007ec6)](https://github.com/bblanchon/ArduinoJson)
[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat)](https://github.com/bblanchon/ArduinoJson/stargazers)
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
## Features
* JSON decoding (comments are supported)
* JSON encoding (with optional indentation)
* MessagePack
* Elegant API, easy to use
* Fixed memory allocation (zero malloc)
* No data duplication (zero copy)
* Portable (written in C++98, can be used in any C++ project)
* Self-contained (no external dependency)
* Small footprint
* Input and output streams
* [100% code coverage](https://coveralls.io/github/bblanchon/ArduinoJson)
* [Header-only library](https://en.wikipedia.org/wiki/Header-only)
* [MIT License](https://en.wikipedia.org/wiki/MIT_License)
* [Comprehensive documentation](https://arduinojson.org?utm_source=github&utm_medium=readme)
## Compatibility
ArduinoJson works on the following hardware:
* <img src="https://www.arduino.cc/favicon.ico" height="16" width="16"> Arduino boards: [Uno](https://www.arduino.cc/en/Main/ArduinoBoardUno), [Due](https://www.arduino.cc/en/Main/ArduinoBoardDue), [Mini](https://www.arduino.cc/en/Main/ArduinoBoardMini), [Micro](https://www.arduino.cc/en/Main/ArduinoBoardMicro), [Yun](https://www.arduino.cc/en/Main/ArduinoBoardYun)...
* <img src="http://espressif.com/sites/all/themes/espressif/favicon.ico" height="16" width="16"> Espressif chips: [ESP8266](https://en.wikipedia.org/wiki/ESP8266), [ESP32](https://en.wikipedia.org/wiki/ESP32)
* <img src="https://www.wemos.cc/themes/martin-materialize-parallax/assets/favicon.ico" height="16" width="16"> WeMos boards: [D1](https://wiki.wemos.cc/products:d1:d1), [D1 mini](https://wiki.wemos.cc/products:d1:d1_mini), ...
* <img src="http://redbearlab.com/favicon.ico" height="16" width="16"> RedBearLab boards: [BLE Nano](http://redbearlab.com/blenano/), [BLE Mini](http://redbearlab.com/blemini/), [WiFi Micro](https://redbear.cc/product/wifi/wifi-micro.html), [LOLIN32](https://wiki.wemos.cc/products:lolin32:lolin32)...
* <img src="https://www.pjrc.com/favicon.ico" height="16" width="16"> [Teensy](https://www.pjrc.com/teensy/) boards
* <img src="https://software.intel.com/sites/all/themes/zero/favicon.ico" height="16" width="16"> Intel boards: Edison, Galileo...
* <img src="https://www-assets.particle.io/images/favicon.png" height="16" width="16"> Particle boards: [Photon](https://www.particle.io/products/hardware/photon-wifi-dev-kit), [Electron](https://www.particle.io/products/hardware/electron-cellular-dev-kit)...
* <img src="http://www.ti.com/favicon.ico" height="16" width="16"> Texas Instruments boards: [MSP430](http://www.ti.com/microcontrollers/msp430-ultra-low-power-mcus/overview/overview.html)...
ArduinoJson compiles with zero warning on the following compilers, IDEs, and platforms:
* <img src="https://www.arduino.cc/favicon.ico" height="16" width="16"> [Arduino IDE](https://www.arduino.cc/en/Main/Software)
* <img src="http://cdn.platformio.org/favicon.ico" height="16" width="16"> [PlatformIO](http://platformio.org/)
* <img src="http://energia.nu/img/favicon.ico" height="16" width="16"> [Energia](http://energia.nu/)
* <img src="http://www.visualmicro.com/pics/arduino-visual-studio-ld.png" height="16" width="16"> [Visual Micro](http://www.visualmicro.com/)
* <img src="http://www.atmel.com/Images/favicon.ico" height="16" width="16"> [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/)
* <img src="https://www.iar.com/favicon.ico" height="16" width="16"> [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/)
* <img src="http://www.st.com/etc/clientlibs/st-site/media/app/images/favicon.png" height="16" width="16"> [Atollic TrueSTUDIO](https://atollic.com/truestudio/)
* <img src="http://www.keil.com/favicon.ico" height="16" width="16"> [Keil uVision](http://www.keil.com/)
* <img src="http://www.microchip.com/favicon.ico" height="16" width="16"> [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide)
* <img src="https://gcc.gnu.org/favicon.ico" height="16" width="16"> [GCC](https://gcc.gnu.org/)
* <img src="https://clang.llvm.org/favicon.ico" height="16" width="16"> [Clang](https://clang.llvm.org/)
* <img src="https://www.visualstudio.com/favicon.ico" height="16" width="16"> [Visual Studio](https://www.visualstudio.com/)
* [JSON deserialization](https://arduinojson.org/v6/api/json/deserializejson/)
* [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v6/api/config/decode_unicode/)
* [Optionally stores links to the input buffer (zero-copy)](https://arduinojson.org/v6/api/json/deserializejson/)
* [Optionally supports comments in the input](https://arduinojson.org/v6/api/config/enable_comments/)
* Supports single quotes as a string delimiter
* Compatible with NDJSON and JSON Lines
* [JSON serialization](https://arduinojson.org/v6/api/json/serializejson/)
* [Can write to a buffer or a stream](https://arduinojson.org/v6/api/json/serializejson/)
* [Optionally indents the document (prettified JSON)](https://arduinojson.org/v6/api/json/serializejsonpretty/)
* [MessagePack serialization](https://arduinojson.org/v6/api/msgpack/serializemsgpack/)
* [MessagePack deserialization](https://arduinojson.org/v6/api/msgpack/deserializemsgpack/)
* Efficient
* [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
* [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
* [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
* [Fixed memory allocation, no heap fragmentation](https://arduinojson.org/v6/api/jsondocument/)
* [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/)
* Versatile
* [Supports custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/)
* 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/)
* Supports Arduino's `Stream` and [STL's `std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/)
* [Supports Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/)
* 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](https://en.wikipedia.org/wiki/Header-only)
* Works with virtually any board
* 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)...
* Espressif chips: [ESP8266](https://amzn.to/36YluV8), [ESP32](https://amzn.to/2G4pRCB)
* Lolin (WeMos) boards: [D1 mini](https://amzn.to/2QUpz7q), [D1 Mini Pro](https://amzn.to/36UsGSs)...
* Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj)
* Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)...
* Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)...
* Tested on all major development environments
* [Arduino IDE](https://www.arduino.cc/en/Main/Software)
* [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/)
* [Atollic TrueSTUDIO](https://atollic.com/truestudio/)
* [Energia](http://energia.nu/)
* [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/)
* [Keil uVision](http://www.keil.com/)
* [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide)
* [PlatformIO](http://platformio.org/)
* [Sloeber plugin for Eclipse](https://eclipse.baeyens.it/)
* [Visual Micro](http://www.visualmicro.com/)
* [Visual Studio](https://www.visualstudio.com/)
* [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/t7KP7I6dVuLhqzDl)
* Well designed
* [Elegant API](http://127.0.0.1:4000/v6/example/)
* [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety)
* Self-contained (no external dependency)
* `const` friendly
* `for` friendly
* [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming)
* Well tested
* [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
* Continuously tested on
* [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
* [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8](https://travis-ci.org/bblanchon/ArduinoJson)
* [Clang 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8](https://travis-ci.org/bblanchon/ArduinoJson)
* [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
* Well documented
* [Tutorials](https://arduinojson.org/v6/doc/deserialization/)
* [Examples](https://arduinojson.org/v6/example/)
* [How-tos](https://arduinojson.org/v6/example/)
* [FAQ](https://arduinojson.org/v6/faq/)
* [Book](https://arduinojson.org/book/)
* Vibrant user community
* 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)
* [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson)
* [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed)
## Quickstart
@ -96,16 +126,7 @@ serializeJson(doc, Serial);
See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme)
## Documentation
The documentation is available on [arduinojson.org](https://arduinojson.org/?utm_source=github&utm_medium=readme), here are some shortcuts:
* The [Examples](https://arduinojson.org/example/?utm_source=github&utm_medium=readme) show how to use the library in various situations.
* The [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=readme) contains the description of each class and function.
* The [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=readme) has the answer to virtually every question.
* The [ArduinoJson Assistant](https://arduinojson.org/assistant/?utm_source=github&utm_medium=readme) writes programs for you!
---
## Support the project
Do you like this library? Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)!

View File

@ -1,6 +1,8 @@
version: 6.11.0.{build}
version: 6.14.0.{build}
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
CMAKE_GENERATOR: Visual Studio 16 2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: Visual Studio 15 2017
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015

1
component.mk Normal file
View File

@ -0,0 +1 @@
COMPONENT_ADD_INCLUDEDIRS := src

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to store your project configuration in a file.
@ -11,6 +11,12 @@
// "port": 2731
// }
//
// To run this program, you need an SD card connected to the SPI bus as follows:
// * MOSI <-> pin 11
// * MISO <-> pin 12
// * CLK <-> pin 13
// * CS <-> pin 4
//
// https://arduinojson.org/v6/example/config/
#include <ArduinoJson.h>
@ -111,7 +117,8 @@ void setup() {
while (!Serial) continue;
// Initialize SD library
while (!SD.begin()) {
const int chipSelect = 4;
while (!SD.begin(chipSelect)) {
Serial.println(F("Failed to initialize SD library"));
delay(1000);
}

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to parse a JSON document in an HTTP response.

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to deserialize a JSON document with ArduinoJson.

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to implement an HTTP server that sends a JSON document

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to send a JSON document to a UDP socket.

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to deserialize a MessagePack document with

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows the different ways you can use Flash strings with

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows the different ways you can use String with ArduinoJson.

View File

@ -5,4 +5,5 @@ make
make test
pip install --user cpp-coveralls 'requests[security]'
coveralls --exclude third-party --gcov-options '\-lp'; fi
pwd
coveralls --include 'src' --gcov-options '\-lp'

View File

@ -2,7 +2,7 @@
ROOT_DIR=$(dirname $0)/../../
INCLUDE_DIR=${ROOT_DIR}/src/
FUZZING_DIR=${ROOT_DIR}/fuzzing/
FUZZING_DIR=${ROOT_DIR}/extras/fuzzing/
CXXFLAGS="-g -fprofile-instr-generate -fcoverage-mapping -fsanitize=address,undefined,fuzzer -fno-sanitize-recover=all"
fuzz() {

View File

@ -2,8 +2,6 @@
pip install --user platformio
rm -r test
case $BOARD in
uno)
platformio lib install 868 # SD library

View File

@ -1,5 +1,5 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2019
# Copyright Benoit Blanchon 2014-2020
# MIT License
if(MSVC)

View File

@ -1,6 +1,6 @@
# CAUTION: this file is invoked by https://github.com/google/oss-fuzz
CXXFLAGS += -I../src -DARDUINOJSON_DEBUG
CXXFLAGS += -I../../src -DARDUINOJSON_DEBUG
all: \
$(OUT)/json_fuzzer \
@ -10,7 +10,7 @@ all: \
$(OUT)/msgpack_fuzzer_seed_corpus.zip \
$(OUT)/msgpack_fuzzer.options
$(OUT)/%_fuzzer: %_fuzzer.cpp $(shell find ../src -type f)
$(OUT)/%_fuzzer: %_fuzzer.cpp $(shell find ../../src -type f)
$(CXX) $(CXXFLAGS) $< -o$@ $(LIB_FUZZING_ENGINE)
$(OUT)/%_fuzzer_seed_corpus.zip: %_seed_corpus/*

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
// This file is NOT use by Google's OSS fuzz

View File

@ -3,7 +3,7 @@
TAG=$(git describe)
OUTPUT="ArduinoJson-$TAG.zip"
cd $(dirname $0)/../..
cd $(dirname $0)/../../..
# remove existing file
rm -f $OUTPUT

View File

@ -0,0 +1,81 @@
#!/bin/bash
set -e
TAG=$(git describe)
RE_RELATIVE_INCLUDE='^#include[[:space:]]*"(.*)"'
RE_ABSOLUTE_INCLUDE='^#include[[:space:]]*<(ArduinoJson/.*)>'
RE_SYSTEM_INCLUDE='^#include[[:space:]]*<(.*)>'
RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
SRC_DIRECTORY="$(realpath "$(dirname $0)/../../src")"
declare -A INCLUDED
process()
{
local PARENT=$1
local FOLDER=$(dirname $1)
local SHOW_COMMENT=$2
while IFS= read -r LINE; do
if [[ $LINE =~ $RE_ABSOLUTE_INCLUDE ]]; then
local CHILD=${BASH_REMATCH[1]}
local CHILD_PATH
CHILD_PATH=$(realpath "$SRC_DIRECTORY/$CHILD")
echo "$PARENT -> $CHILD" >&2
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
INCLUDED[$CHILD_PATH]=true
process "$CHILD" false
fi
elif [[ $LINE =~ $RE_RELATIVE_INCLUDE ]]; then
local CHILD=${BASH_REMATCH[1]}
pushd "$FOLDER" > /dev/null
local CHILD_PATH
CHILD_PATH=$(realpath "$CHILD")
echo "$PARENT -> $CHILD" >&2
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
INCLUDED[$CHILD_PATH]=true
process "$CHILD" false
fi
popd > /dev/null
elif [[ $LINE =~ $RE_SYSTEM_INCLUDE ]]; then
local CHILD=${BASH_REMATCH[1]}
echo "$PARENT -> <$CHILD>" >&2
if [[ ! ${INCLUDED[$CHILD]} ]]; then
echo "#include <$CHILD>"
INCLUDED[$CHILD]=true
fi
elif [[ "${SHOW_COMMENT}" = "true" ]] ; then
echo "$LINE"
elif [[ ! $LINE =~ $RE_EMPTY ]]; then
echo "$LINE"
fi
done < $PARENT
}
simplify_namespaces() {
perl -p0i -e 's|\} // namespace ARDUINOJSON_NAMESPACE\r?\nnamespace ARDUINOJSON_NAMESPACE \{\r?\n||igs' "$1"
}
cd $(dirname $0)/../..
INCLUDED=()
process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
simplify_namespaces ../ArduinoJson-$TAG.h
g++ -x c++ -c -o ../smoketest.o - <<END
#include "../ArduinoJson-$TAG.h"
int main() {
StaticJsonDocument<300> doc;
deserializeJson(doc, "{}");
}
END
INCLUDED=()
process src/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp
simplify_namespaces ../ArduinoJson-$TAG.hpp
g++ -x c++ -c -o ../smoketest.o - <<END
#include "../ArduinoJson-$TAG.hpp"
int main() {
ArduinoJson::StaticJsonDocument<300> doc;
ArduinoJson::deserializeJson(doc, "{}");
}
END

View File

@ -2,7 +2,7 @@
export PATH="$PATH:/Applications/CMake.app/Contents/bin/"
cd $(dirname $0)/..
cd $(dirname $0)/../..
ROOT=$(pwd)
mkdir "build"

View File

@ -2,7 +2,7 @@
set -eu
SOURCE_DIR="$(dirname "$0")/.."
SOURCE_DIR="$(dirname "$0")/../.."
WORK_DIR=$(mktemp -d)
trap 'rm -rf "$WORK_DIR"' EXIT

8
scripts/publish.sh → extras/scripts/publish.sh Normal file → Executable file
View File

@ -2,7 +2,7 @@
set -eu
cd "$(dirname "$0")/.."
cd "$(dirname "$0")/../.."
VERSION="$1"
DATE=$(date +%F)
@ -56,6 +56,6 @@ commit_new_version
add_tag
push
scripts/build-arduino-package.sh
scripts/build-single-header.sh
scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h"
extras/scripts/build-arduino-package.sh
extras/scripts/build-single-header.sh
extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h"

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to deserialize a JSON document with ArduinoJson.

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.

View File

View File

@ -1,7 +1,9 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2019
# Copyright Benoit Blanchon 2014-2020
# MIT License
add_subdirectory(catch)
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(
-pedantic
@ -70,6 +72,7 @@ if(MSVC)
)
endif()
include_directories(Helpers)
add_subdirectory(ElementProxy)
add_subdirectory(IntegrationTests)
add_subdirectory(JsonArray)

View File

@ -1,10 +1,11 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2019
# Copyright Benoit Blanchon 2014-2020
# MIT License
add_executable(ElementProxyTests
add.cpp
clear.cpp
compare.cpp
remove.cpp
set.cpp
size.cpp

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -0,0 +1,28 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("ElementProxy::operator==()") {
DynamicJsonDocument doc(4096);
SECTION("same value") {
doc.add(1);
doc.add(1);
REQUIRE(doc[0] == doc[1]);
REQUIRE_FALSE(doc[0] != doc[1]);
}
SECTION("different values") {
doc.add(1);
doc.add(2);
REQUIRE_FALSE(doc[0] == doc[1]);
REQUIRE(doc[0] != doc[1]);
}
}

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -0,0 +1,26 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#pragma once
#include <sstream>
class CustomReader {
std::stringstream _stream;
public:
CustomReader(const char* input) : _stream(input) {}
int read() {
return _stream.get();
}
size_t readBytes(char* buffer, size_t length) {
_stream.read(buffer, static_cast<std::streamsize>(length));
return static_cast<size_t>(_stream.gcount());
}
private:
CustomReader(const CustomReader&);
};

View File

@ -0,0 +1,14 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#pragma once
// Reproduces Arduino's Stream class
class Stream // : public Print
{
public:
virtual ~Stream() {}
virtual int read() = 0;
virtual size_t readBytes(char *buffer, size_t length) = 0;
};

View File

@ -0,0 +1,42 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#pragma once
#include <string>
// Reproduces Arduino's String class
class String {
public:
String& operator+=(const char* rhs) {
_str += rhs;
return *this;
}
size_t length() const {
return _str.size();
}
const char* c_str() const {
return _str.c_str();
}
bool operator==(const char* s) const {
return _str == s;
}
friend std::ostream& operator<<(std::ostream& lhs, const ::String& rhs) {
lhs << rhs._str;
return lhs;
}
private:
std::string _str;
};
class StringSumHelper;
inline bool operator==(const std::string& lhs, const ::String& rhs) {
return lhs == rhs.c_str();
}

View File

@ -1,5 +1,5 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2019
# Copyright Benoit Blanchon 2014-2020
# MIT License
add_executable(IntegrationTests

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2019
# Copyright Benoit Blanchon 2014-2020
# MIT License
add_executable(JsonArrayTests

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -0,0 +1,58 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::isNull()") {
SECTION("returns true") {
JsonArray arr;
REQUIRE(arr.isNull() == true);
}
SECTION("returns false") {
DynamicJsonDocument doc(4096);
JsonArray arr = doc.to<JsonArray>();
REQUIRE(arr.isNull() == false);
}
}
TEST_CASE("JsonArrayConst::isNull()") {
SECTION("returns true") {
JsonArrayConst arr;
REQUIRE(arr.isNull() == true);
}
SECTION("returns false") {
DynamicJsonDocument doc(4096);
JsonArrayConst arr = doc.to<JsonArray>();
REQUIRE(arr.isNull() == false);
}
}
TEST_CASE("JsonArray::operator bool()") {
SECTION("returns false") {
JsonArray arr;
REQUIRE(static_cast<bool>(arr) == false);
}
SECTION("returns true") {
DynamicJsonDocument doc(4096);
JsonArray arr = doc.to<JsonArray>();
REQUIRE(static_cast<bool>(arr) == true);
}
}
TEST_CASE("JsonArrayConst::operator bool()") {
SECTION("returns false") {
JsonArrayConst arr;
REQUIRE(static_cast<bool>(arr) == false);
}
SECTION("returns true") {
DynamicJsonDocument doc(4096);
JsonArrayConst arr = doc.to<JsonArray>();
REQUIRE(static_cast<bool>(arr) == true);
}
}

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>

Some files were not shown because too many files have changed in this diff Show More