Compare commits

..

143 Commits

Author SHA1 Message Date
6a71f31820 Set version to 6.18.4 2021-09-06 09:11:22 +02:00
3428ab1e89 Added a comment to easily diagnose issue #1648 2021-09-03 08:31:51 +02:00
956e4a7cbb Fixed deserialization of \u0000 (issue #1646) 2021-08-31 14:23:58 +02:00
669bad27d4 CI: added a workaround for adafruit/Adafruit_nRF52_Arduino#653 2021-08-22 18:01:56 +02:00
2c3ae1c181 Filter: exact match takes precedence over wildcard (fixes #1628) 2021-08-13 10:35:15 +02:00
f570fe8c37 Fixed error expected unqualified-id on GCC 11 (fixes #1622) 2021-08-03 11:39:18 +02:00
1b74ad0731 Fixed error 'dummy' may be used uninitialized on GCC 11 2021-08-03 11:39:07 +02:00
6717700d3b CI: added GCC 11 2021-08-03 10:42:37 +02:00
b810833145 Set version to 6.18.3 2021-07-27 15:44:36 +02:00
9d58e566fd Added as<std::string_view>() and is<std::string_view>() 2021-07-27 14:16:39 +02:00
6632fa8da1 Removed StringAdapter::equals() 2021-07-27 14:16:39 +02:00
5790f3c8f7 Refactored string adapters: only one IsString<T> and adaptString() 2021-07-27 14:16:18 +02:00
4073b52c00 Changed return type of convertToJson() and Converter::toJson() to void 2021-07-23 15:11:48 +02:00
f5c7a6478e Publish script: fixed frontmatter for arduinojson.org 2021-07-19 10:19:04 +02:00
ebf58320ca Set version to 6.18.2 2021-07-19 10:11:21 +02:00
09ddb0f824 Publish script: generate the file for arduinojson.org 2021-07-19 09:58:01 +02:00
f02a699c26 CI: added a workflow to create a release when matching tag is pushed 2021-07-16 11:06:50 +02:00
67d0931c19 Added parameters to script build-arduino-package.sh 2021-07-16 09:35:32 +02:00
19d079c33c Removed a symlink because the Arduino Library Specification forbids it 2021-07-15 12:50:22 +02:00
40723a4cc7 CI: check that the repository doesn't contain any symlink
The Arduino Library Specification forbids symlinks, that's probably the reason why version 6.18.1 is missing from the Library Manager.
2021-07-15 12:50:22 +02:00
8a9a26588c Fixed publish script 2021-07-03 16:08:36 +02:00
219475630a Set version to 6.18.1 2021-07-03 16:03:01 +02:00
52e856fa6f CI: added ESP-IDF component build (closes #1599) 2021-06-30 13:34:59 +02:00
cb2c029e57 Added support for ESP-IDF component build (closes #1562) 2021-06-30 10:29:28 +02:00
ef7579394b Fixed JsonVariant::as<unsigned>() (fixes #1601) 2021-06-30 09:58:03 +02:00
fc4f175300 CI: fixed ARM compiler installation 2021-06-28 09:10:15 +02:00
a6fc9311b4 Added JsonArray::clear() (fixes #1597) 2021-06-26 11:29:15 +02:00
14639f129e CMake: added empty line at end of each file 2021-06-26 11:29:15 +02:00
9182c2068d Fixed build-single-header.sh (fixes #1592) 2021-06-21 16:11:02 +02:00
cb1b3be723 CI: build single headers 2021-06-21 16:11:02 +02:00
5ccd62a789 Updated the readme 2021-06-18 11:39:00 +02:00
145d45c746 Fixed warning on Clang 10 2021-06-17 20:41:04 +02:00
f235157466 Added support for std::string_view (closes #1578, closes #1554) 2021-06-17 20:41:04 +02:00
ba5cdab619 Test: extracted executable Cpp11Tests 2021-06-17 20:28:09 +02:00
eab5ae2f07 Simplified string adapters 2021-06-16 21:08:05 +02:00
2f0b3c0e63 VSCode: added devcontainer configuration 2021-06-16 21:08:05 +02:00
4e261068a1 clang-format: set IndentPPDirectives to AfterHash 2021-06-16 21:08:01 +02:00
1d24caf066 Added InvalidConversion to identify invalid conversions (closes #1585) 2021-06-11 11:54:52 +02:00
dc76c5165f Fixed clang-tidy warnings (fixes #1574) 2021-06-04 12:00:33 +02:00
de11b36a98 clang-tidy: muted "uninitialized pointer/field" in StringCopier 2021-06-04 11:38:21 +02:00
c4a4ed5272 clang-tidy: muted "uninitialized field" in Latch 2021-06-04 11:37:07 +02:00
a24edac5a9 clang-tidy: muted "use of memory after it is freed" in MemoryPool 2021-06-04 11:37:07 +02:00
9dbf44388d clang-tidy: muted "call to function is insecure" in tests 2021-06-04 11:37:07 +02:00
6b8e93e05e clang-tidy: fixed "uninitialized field" in VariantData 2021-06-04 11:36:20 +02:00
6b5239b9d5 clang-tidy: removed unused field 2021-06-04 11:16:24 +02:00
214c06b771 clang-tidy: fixed clang-analyzer-optin.cplusplus.UninitializedObject 2021-06-04 11:16:17 +02:00
e32a8552be CI: added clang-tidy (closes #1577) 2021-06-04 11:00:16 +02:00
9bcb409648 Fixed serializeJson(doc, String) when allocation fails (fixes #1572) 2021-05-30 21:34:07 +02:00
3b10afd2ab CI: test more platforms on PlatformIO 2021-05-30 18:45:40 +02:00
af3bb131c8 Fixed error Pe070 "incomplete type is not allowed" on IAR (fixes #1560) 2021-05-19 15:07:59 +02:00
622e7dd287 Fixed support for volatile float and double (fixes #1557) 2021-05-19 15:01:51 +02:00
68082e6fc1 CI: use libc++ for Clang 3.5 to 4.0
The fixes the error: "__STRICT_ANSI__ seems to have been undefined; this is not supported" with Clang 3.9
2021-05-17 09:06:28 +02:00
36bcc7b355 Set version to 6.18.0 2021-05-05 20:41:35 +02:00
c7c0b729c1 Added a deprecation warning for is<char>() and is<char*>() 2021-05-05 15:43:02 +02:00
6aeefda3b6 CI: Skip WillFail and Fuzzing test labels when measuring coverage 2021-05-04 16:36:21 +02:00
4780174ee1 Added a deprecation warning for as<char>() and set(char) 2021-05-04 16:10:50 +02:00
ab23625091 Renamed DEPRECATED to ARDUINOJSON_DEPRECATED 2021-05-04 14:44:07 +02:00
a88cf8fab7 PlatformIO: set build.libArchive to false (closes #1550) 2021-05-03 08:55:20 +02:00
2be528a3fa serializeMsgPack(doc, p, n) doesn't add terminator anymore (fixes #1545) 2021-04-29 20:59:15 +02:00
337864618c Reversed parameters of convertToJson() and convertFromJson()
Now the order matches copyArray(): source first, destination second.
2021-04-28 10:25:39 +02:00
526cad54d7 VSCode: insert final new line 2021-04-27 18:25:42 +02:00
506cf7f438 Added .prettierignore 2021-04-27 18:25:42 +02:00
4b89878c10 Added a deprecation warning for as<char*>() 2021-04-27 18:25:42 +02:00
06fad301cb CI: added Valgrind job (closes #1542) 2021-04-25 20:58:22 +02:00
7be0c2c650 CMake: added labels to tests 2021-04-25 11:38:19 +02:00
43f0db45ad Updated Catch library to 1.12.2 2021-04-22 08:54:16 +02:00
892c37db08 Optimized JsonVariant::is<float>() 2021-04-21 13:21:40 +02:00
d8a1d1a120 Increased coverage of ConverterImpl.hpp 2021-04-18 17:23:51 +02:00
64e52e97ee Removed redundant range check in MemoryPoolPrint 2021-04-18 16:47:28 +02:00
2a777a659a Fixed reference-binding-to-null-pointer in MsgPack deserializer 2021-04-15 14:56:59 +02:00
898f429826 Fixed member-call-on-null-pointer in getMember() when array is empty 2021-04-15 14:56:59 +02:00
88fbe3ac34 Fixed undefined behavior in JSON serializer 2021-04-15 14:56:59 +02:00
4ddc674846 CI: fixed sanitizers errors not been reported 2021-04-15 11:11:50 +02:00
fc4f5fd05f Changed integer storage from positive/negative to signed/unsigned 2021-04-14 11:45:01 +02:00
a002393716 Replaced donation link 2021-04-14 11:45:01 +02:00
a889f6560c Added VSCode settings 2021-04-14 11:43:51 +02:00
4db17ecd93 CI: format YAML file with Prettier 2021-04-08 09:46:01 +02:00
2a57f2b365 CI: fix installation of GCC and Clang 2021-04-08 09:45:04 +02:00
803e07c188 Updated folders list in .mbedignore (closes #1515) 2021-03-31 09:58:51 +02:00
ff44d93e68 Removed buggy blank line in CHANGELOG 2021-03-29 19:35:25 +02:00
d5d2209d09 Added "https://" prefix to all URLs so they are clickable in VS Code 2021-03-29 19:35:25 +02:00
c81e8fc93a README: added a link to ARDUINOJSON_ENABLE_ARDUINO_STREAM 2021-03-29 18:10:00 +02:00
347ac422f4 Added support for Printable (closes #1444) 2021-03-27 14:35:15 +01:00
d7f5b56ca4 Added support for custom converters (closes #687) 2021-03-20 14:52:47 +01:00
53d6f0d492 CI: Fixed build on Arduino 1.6.7 2021-03-19 11:50:29 +01:00
e4ce75e20c Simplified JsonVariant::as<T>() to always return T 2021-03-08 19:33:52 +01:00
9094179856 CI: added a clang-format job 2021-02-26 13:13:11 +01:00
3aab36fec2 Changed JsonVariantConst::is<JsonArray/JsonObject>() to return false (closes #1412) 2021-02-25 19:19:23 +01:00
744d61f6fd Added JsonVariant::is<JsonVariant/JsonVariantConst>() (issue #1412) 2021-02-23 08:41:24 +01:00
05498aa178 Added JsonVariant::is<JsonVariant>() (issue #1412) 2021-02-23 08:39:58 +01:00
b1eb273d5b Added JsonVariant::is<JsonArrayConst/JsonObjectConst>() (issue #1412) 2021-02-23 08:33:28 +01:00
8a3f8510d6 Simplified tests of JsonVariant::is<T>() 2021-02-23 08:27:48 +01:00
22904a48a6 Added a default implementation in the Visitor class 2021-02-21 13:37:07 +01:00
1730304f46 Funding: added paypal.me 2021-02-21 12:24:46 +01:00
1038fc35df Removed DeserializationError::NotSupported 2021-02-18 19:41:15 +01:00
71f44aaee1 deserializeMsgPack() inserts null instead of returning NotSupported 2021-02-18 19:40:25 +01:00
cc7ebfd11e deserializeJson() leaves \uXXXX instead of returning NotSupported 2021-02-18 19:40:11 +01:00
54d4b308f4 Remove JsonVariant::set(char) 2021-02-18 08:48:28 +01:00
5234c8124b Removed JsonVariant::as<char>() (fixes #1498) 2021-02-18 08:48:10 +01:00
e22d4bf31f Set version to 6.17.3 2021-02-15 09:53:10 +01:00
21f7b90f03 PlatformIO: set framework compatibility to * (closes #1490) 2021-02-15 09:49:56 +01:00
769e8440f5 CI: skip Particle job for Pull Requests 2021-02-05 13:00:56 +01:00
33de2b6cf3 Added GitHub sponsors 2021-02-05 12:03:50 +01:00
3975b07371 Moved CI from Travis to GitHub Actions (fixes #1493) 2021-02-03 21:33:18 +01:00
abd64102aa Fixed compilation error on Clang 10 2021-02-03 12:56:26 +01:00
d2174d1580 Fixed compilation error when isdigit() is a macro (fixes #1487) 2021-02-02 10:08:10 +01:00
c72eccdd35 Added missing calls to client.stop() in JsonHttpClient.ino (fixes #1485) 2021-02-01 09:16:23 +01:00
ab902128dc Upgrade to Lock Threads 2 2021-01-31 11:00:05 +01:00
c70a491f59 Made JsonDocument's destructor protected (fixes #1480) 2021-01-27 10:00:10 +01:00
322d13de0d Examples: add a note about performance issues with streams (#1476) 2021-01-25 09:26:29 +01:00
97b7161d78 Update copyright notice for 2021 2021-01-25 09:14:15 +01:00
1360b6a396 Set version to 6.17.2 2020-11-14 10:38:21 +01:00
16e51b83ab Changed the default value of ARDUINOJSON_ENABLE_PROGMEM (fixes #1433)
It now checks that the pgm_read_XXX macros are defined before enabling PROGMEM.
2020-11-10 14:58:31 +01:00
aa7cc5351c Travis: added smoke test for Particle Argon 2020-11-10 14:46:45 +01:00
30da920135 Fixed invalid conversion in operator|(Variant, char*) (fixes #1432) 2020-11-09 09:21:19 +01:00
bcdf5b7e52 Set version to 6.17.1 2020-11-07 10:11:41 +01:00
c711fe592d Allowed more than 32767 values in non-embedded mode (fixes #1414) 2020-10-28 09:59:40 +01:00
9d5c1b3742 Added an assert to detect too large variants (issue #1414) 2020-10-24 09:39:03 +02:00
6b26cd0977 Add JsonDocument to keywords.txt
see #1413
2020-10-24 09:37:16 +02:00
10ec0f21b0 Fixed operator|(MemberProxy, JsonObject) (fixes #1415) 2020-10-23 10:48:33 +02:00
ff66182dc6 Gathered the tests of MemberProxy in one file 2020-10-22 09:37:05 +02:00
d02ce2f1bb Gathered the tests of ElementProxy in one file 2020-10-22 09:37:05 +02:00
2664a2d0da Fixed error "ambiguous overload for operator|" (fixes #1411) 2020-10-22 09:30:31 +02:00
1f7350658e Set version to 6.17.0 2020-10-19 11:35:09 +02:00
41132b701b Fixed error "no matching function for pgm_read<double>()" on AVR 2020-10-17 14:02:26 +02:00
712005219c Added filtering for MessagePack (closes #1298, closes #1394) 2020-10-13 09:40:39 +02:00
0bd17aff8a Coverage: use -O0 instead of -Og 2020-10-11 15:10:52 +02:00
f3f44d7812 Renamed StdStringAdapter to StlStringAdapter (internal use only) 2020-10-01 10:01:33 +02:00
8385d5fa3a Added wildcard key (*) for filters (closes #1309) 2020-09-28 21:11:38 +02:00
726f8be341 Added operator|(JsonVariantConst, JsonVariantConst) 2020-09-26 14:48:17 +02:00
fee029b86e Moved float tables to PROGMEM 2020-09-19 16:12:49 +02:00
c3504ddf0a Added tests for DeserializationError::f_str() 2020-09-18 19:06:21 +02:00
6a878ee444 Fixed error "No such file or directory WString.h" (fixes #1381) 2020-09-16 10:29:20 +02:00
c4ec2ba88f Added DeserializationError::f_str() (issue #846) 2020-09-14 18:40:00 +02:00
c907ca6e5d Added DeserializationError::EmptyInput 2020-09-13 10:27:29 +02:00
8993a093e9 Travis: run sanitizer on recent GCC version to avoid false positives 2020-09-13 10:25:34 +02:00
d04669d0cc Fixed result of JsonVariant::set((char*)0) (fixes #1368) 2020-09-05 17:33:47 +02:00
05fc136915 Disabled memory sanitizer with clang 6 2020-09-05 13:44:40 +02:00
8d37939086 Added JsonDocument::overflowed() (closes #1358) 2020-09-05 13:44:40 +02:00
6d2ad4539f Simplified the implementation of parseNumber() 2020-09-04 09:23:40 +02:00
5ab53f42b2 Added a return value to visitors 2020-08-29 18:40:27 +02:00
f448e805e9 Removed dead code 2020-08-25 14:36:14 +02:00
67aa8efd5a Added a build failure when nullptr is defined as a macro (closes #1355) 2020-08-23 09:31:40 +02:00
413 changed files with 8107 additions and 4035 deletions

View File

@ -3,6 +3,8 @@
BasedOnStyle: Google
Standard: Cpp03
AllowShortFunctionsOnASingleLine: Empty
IncludeBlocks: Preserve
IndentPPDirectives: AfterHash
# Always break after if to get accurate coverage
AllowShortIfStatementsOnASingleLine: false

45
.devcontainer/Dockerfile Normal file
View File

@ -0,0 +1,45 @@
FROM ubuntu:20.04
RUN apt-get update && \
apt-get install -y software-properties-common curl && \
apt-get upgrade -y
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
RUN add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main' && \
add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe' && \
add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main' && \
add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe' && \
add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main' && \
add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe' && \
add-apt-repository -yn 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-6.0 main' && \
add-apt-repository -yn 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main' && \
add-apt-repository -yn 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main' && \
add-apt-repository -yn 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main' && \
add-apt-repository -yn 'deb http://mirrors.kernel.org/ubuntu hirsute main universe'
RUN apt-get update && apt-get -y install \
cmake \
ninja-build \
git \
clang-format \
g++-4.4 \
g++-4.6 \
g++-4.7 \
g++-4.8 \
g++-4.9 \
g++-5 \
g++-7 \
g++-8 \
g++-9 \
g++-10 \
g++-11 \
clang-3.5 \
clang-3.6 \
clang-3.7 \
clang-3.8 \
clang-3.9 \
clang-6.0 \
clang-7 \
clang-8 \
clang-9 \
clang-10 \
clang-11

View File

@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/ubuntu
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile"
},
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"xaver.clang-format"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
}

5
.github/FUNDING.yml vendored
View File

@ -1 +1,4 @@
custom: https://arduinojson.org/book/
github: bblanchon
custom:
- https://arduinojson.org/book/
- https://donate.benoitblanchon.fr/

7
.github/lock.yml vendored
View File

@ -1,7 +0,0 @@
# 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

489
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,489 @@
name: Continuous Integration
on: [push, pull_request]
jobs:
lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- name: Install
run: sudo apt-get install -y clang-format
- name: Checkout
uses: actions/checkout@v2
- name: Symlinks
run: find * -type l -printf "::error::%p is a symlink. This is forbidden by the Arduino Library Specification." -exec false {} +
- name: Clang-format
run: |
find src/ extras/ -name '*.[ch]pp' | xargs clang-format -i --verbose --style=file
git diff --exit-code
gcc:
name: GCC
needs: lint
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- gcc: "4.4"
- gcc: "4.6"
- gcc: "4.7"
- gcc: "4.8"
- gcc: "4.9"
- gcc: "5"
- gcc: "6"
- gcc: "7"
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
- gcc: "8"
cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
- gcc: "9"
cxxflags: -fsanitize=address -fno-sanitize-recover=all
- gcc: "10"
- gcc: "11"
steps:
- name: Install
run: |
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
sudo add-apt-repository -yn 'deb http://mirrors.kernel.org/ubuntu hirsute main universe'
sudo apt-get update
sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
- name: Checkout
uses: actions/checkout@v2
- name: Configure
run: cmake -DCMAKE_BUILD_TYPE=Debug .
env:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
CXXFLAGS: ${{ matrix.cxxflags }}
- name: Build
run: cmake --build .
- name: Test
run: ctest --output-on-failure -C Debug .
env:
UBSAN_OPTIONS: print_stacktrace=1
clang:
name: Clang
needs: lint
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- clang: "3.5"
cxxflags: "-stdlib=libc++"
- clang: "3.6"
cxxflags: "-stdlib=libc++"
- clang: "3.7"
cxxflags: "-stdlib=libc++"
- clang: "3.8"
cxxflags: "-stdlib=libc++"
- clang: "3.9"
cxxflags: "-stdlib=libc++"
- clang: "4.0"
cxxflags: "-stdlib=libc++"
- clang: "5.0"
- clang: "6.0"
- clang: "7"
- clang: "8"
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
- clang: "9"
cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
- clang: "10"
cxxflags: -fsanitize=address -fno-sanitize-recover=all
steps:
- name: Install
run: |
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
sudo apt-get update
sudo apt-get install -y clang-${{ matrix.clang }}
- name: Checkout
uses: actions/checkout@v2
- name: Configure
run: cmake -DCMAKE_BUILD_TYPE=Debug .
env:
CC: clang-${{ matrix.clang }}
CXX: clang++-${{ matrix.clang }}
CXXFLAGS: >-
${{ matrix.cxxflags }}
${{ contains(matrix.cxxflags, 'libc++') && '-I/usr/lib/llvm-10/include/c++/v1/' || '' }}
- name: Build
run: cmake --build .
- name: Test
run: ctest --output-on-failure -C Debug .
env:
UBSAN_OPTIONS: print_stacktrace=1
xcode:
name: XCode
needs: clang
runs-on: macos-10.15
strategy:
fail-fast: false
matrix:
include:
- xcode: "10.3"
- xcode: "11.7"
- xcode: "12.4"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Select XCode version
run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode }}.app
- name: Configure
run: cmake -DCMAKE_BUILD_TYPE=Debug .
- name: Build
run: cmake --build .
- name: Test
run: ctest --output-on-failure -C Debug .
# DISABLED: Running on AppVeyor instead because it supports older versions of the compiler
# msvc:
# name: Visual Studio
# strategy:
# fail-fast: false
# matrix:
# include:
# - os: windows-2016
# - os: windows-2019
# runs-on: ${{ matrix.os }}
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Configure
# run: cmake -DCMAKE_BUILD_TYPE=Debug .
# - name: Build
# run: cmake --build .
# - name: Test
# run: ctest --output-on-failure -C Debug .
arduino:
name: Arduino
needs: gcc
strategy:
fail-fast: false
matrix:
include:
- arduino: "1.6.7"
os: ubuntu-18.04 # java.lang.Error: Cannot load com.sun.java.swing.plaf.gtk.GTKLookAndFeel
board: arduino:avr:uno
- arduino: "1.8.2"
board: arduino:samd:mkr1000
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: extras/ci/arduino.sh ${{ matrix.board }}
env:
BOARD: ${{ matrix.board }}
VERSION: ${{ matrix.arduino }}
platformio:
name: PlatformIO
needs: gcc
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- platform: atmelavr
board: leonardo
libraries:
- SD
- Ethernet
- platform: espressif8266
board: huzzah
- platform: espressif32
board: esp32dev
libraries:
- Ethernet
- platform: atmelsam
board: mkr1000USB
libraries:
- SD
- Ethernet
- platform: teensy
board: teensy31
- platform: ststm32
board: adafruit_feather_f405
libraries:
- SD
- Ethernet
- platform: nordicnrf52
board: adafruit_feather_nrf52840
libraries:
- SD
- Ethernet
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up cache for pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install PlatformIO
run: pip install platformio
- name: Install adafruit-nrfutil
if: ${{ matrix.platform == 'nordicnrf52' }}
run: pip install adafruit-nrfutil
- name: Include Adafruit_TinyUSB.h # https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/653
if: ${{ matrix.platform == 'nordicnrf52' }}
run: find examples/ -name '*.ino' -exec sed -i 's/\(#include <ArduinoJson.h>\)/\1\n#include <Adafruit_TinyUSB.h>/' {} +
- name: Set up cache for platformio
uses: actions/cache@v2
with:
path: ~/.platformio
key: ${{ runner.os }}-platformio-${{ matrix.platform }}
- name: Install platform "${{ matrix.platform }}"
run: platformio platform install ${{ matrix.platform }}
- name: Install libraries
if: ${{ matrix.libraries }}
run: platformio lib install arduino-libraries/${{ join(matrix.libraries, ' arduino-libraries/') }}
- name: Build JsonConfigFile
run: platformio ci "examples/JsonConfigFile/JsonConfigFile.ino" -l '.' -b ${{ matrix.board }}
- name: Build JsonFilterExample
run: platformio ci "examples/JsonFilterExample/JsonFilterExample.ino" -l '.' -b ${{ matrix.board }}
- name: Build JsonGeneratorExample
run: platformio ci "examples/JsonGeneratorExample/JsonGeneratorExample.ino" -l '.' -b ${{ matrix.board }}
- name: Build JsonHttpClient
run: platformio ci "examples/JsonHttpClient/JsonHttpClient.ino" -l '.' -b ${{ matrix.board }}
- name: Build JsonParserExample
run: platformio ci "examples/JsonParserExample/JsonParserExample.ino" -l '.' -b ${{ matrix.board }}
- name: Build JsonServer
if: ${{ matrix.platform != 'espressif32' }}
run: platformio ci "examples/JsonServer/JsonServer.ino" -l '.' -b ${{ matrix.board }}
- name: Build JsonUdpBeacon
run: platformio ci "examples/JsonUdpBeacon/JsonUdpBeacon.ino" -l '.' -b ${{ matrix.board }}
- name: Build MsgPackParser
run: platformio ci "examples/MsgPackParser/MsgPackParser.ino" -l '.' -b ${{ matrix.board }}
- name: Build ProgmemExample
run: platformio ci "examples/ProgmemExample/ProgmemExample.ino" -l '.' -b ${{ matrix.board }}
- name: Build StringExample
run: platformio ci "examples/StringExample/StringExample.ino" -l '.' -b ${{ matrix.board }}
- name: PlatformIO prune
if: ${{ always() }}
run: platformio system prune -f
particle:
name: Particle
needs: gcc
runs-on: ubuntu-latest
if: github.event_name == 'push'
strategy:
fail-fast: false
matrix:
include:
- board: argon
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Particle CLI
run: sudo npm install -g particle-cli
- name: Login to Particle
run: particle login -t "${{ secrets.PARTICLE_TOKEN }}"
- name: Compile
run: extras/ci/particle.sh ${{ matrix.board }}
arm:
name: GCC for ARM processor
needs: gcc
runs-on: ubuntu-20.04
steps:
- name: Install
run: |
sudo apt-get update
sudo apt-get install -y g++-arm-linux-gnueabihf
- name: Checkout
uses: actions/checkout@v2
- name: Configure
run: cmake .
env:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-g++
- name: Build
run: cmake --build .
coverage:
needs: gcc
name: Coverage
runs-on: ubuntu-20.04
steps:
- name: Install
run: sudo apt-get install -y lcov ninja-build
- name: Checkout
uses: actions/checkout@v2
- name: Configure
run: cmake -G Ninja -DCOVERAGE=true .
- name: Build
run: ninja
- name: Test
run: ctest -LE 'WillFail|Fuzzing' -T test
- name: lcov --capture
run: lcov --capture --no-external --directory . --output-file coverage.info
- name: lcov --remove
run: lcov --remove coverage.info "$(pwd)/extras/*" --output-file coverage_filtered.info
- name: genhtml
run: mkdir coverage && genhtml coverage_filtered.info -o coverage -t ArduinoJson
- name: Upload HTML report
uses: actions/upload-artifact@v2
with:
name: Coverage report
path: coverage
- name: Upload to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage_filtered.info
valgrind:
needs: gcc
name: Valgrind
runs-on: ubuntu-20.04
steps:
- name: Install
run: sudo apt-get install -y valgrind ninja-build
- name: Checkout
uses: actions/checkout@v2
- name: Configure
run: cmake -G Ninja -D MEMORYCHECK_COMMAND_OPTIONS="--error-exitcode=1 --leak-check=full" .
- name: Build
run: ninja
- name: Memcheck
run: ctest -LE WillFail -T memcheck
id: memcheck
- name: MemoryChecker.*.log
run: cat Testing/Temporary/MemoryChecker.*.log
if: failure()
clang-tidy:
needs: clang
name: Clang-Tidy
runs-on: ubuntu-20.04
steps:
- name: Install
run: sudo apt-get install -y clang-tidy cmake ninja-build
- name: Checkout
uses: actions/checkout@v2
- name: Configure
run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy-10;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
env:
CC: clang-10
CXX: clang++-10
- name: Check
run: cmake --build . -- -k 0
amalgamate-h:
needs: gcc
name: Amalgamate ArduinoJson.h
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Amalgamate
id: amalgamate
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${GITHUB_SHA::7}
fi
INPUT=src/ArduinoJson.h
OUTPUT=ArduinoJson-$VERSION.h
extras/scripts/build-single-header.sh "$INPUT" "$OUTPUT"
echo ::set-output name=filename::${OUTPUT}
- name: Smoke test
run: |
g++ -x c++ - <<END
#include "${{ steps.amalgamate.outputs.filename }}"
int main() {
StaticJsonDocument<300> doc;
deserializeJson(doc, "{}");
}
END
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: Single headers
path: ${{ steps.amalgamate.outputs.filename }}
amalgamate-hpp:
needs: gcc
name: Amalgamate ArduinoJson.hpp
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Amalgamate
id: amalgamate
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=${GITHUB_SHA::7}
fi
INPUT=src/ArduinoJson.hpp
OUTPUT=ArduinoJson-$VERSION.hpp
extras/scripts/build-single-header.sh "$INPUT" "$OUTPUT"
echo ::set-output name=filename::${OUTPUT}
- name: Smoke test
run: |
g++ -x c++ - <<END
#include "${{ steps.amalgamate.outputs.filename }}"
int main() {
ArduinoJson::StaticJsonDocument<300> doc;
deserializeJson(doc, "{}");
}
END
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: Single headers
path: ${{ steps.amalgamate.outputs.filename }}
esp-idf:
needs: gcc
name: ESP-IDF
runs-on: ubuntu-latest
steps:
- name: Setup cache
uses: actions/cache@v2
with:
path: ~/.espressif
key: ${{ runner.os }}-esp-idf
- name: Checkout ArduinoJson
uses: actions/checkout@v2
- name: Checkout ESP-IDF
uses: actions/checkout@v2
with:
repository: espressif/esp-idf
path: esp-idf
submodules: true
- name: Install ESP-IDF
run: ./esp-idf/install.sh
- name: Add component
# NOTE: we cannot commit the symlink because the Arduino Library Specification forbids it.
run: |
mkdir -p extras/ci/espidf/components
ln -s $PWD extras/ci/espidf/components/ArduinoJson
- name: Build example
run: |
source esp-idf/export.sh
cd extras/ci/espidf
idf.py build

14
.github/workflows/lock.yml vendored Normal file
View File

@ -0,0 +1,14 @@
name: 'Lock Threads'
on:
schedule:
- cron: '0 0 * * *'
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: 30

51
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: Release
on:
push:
tags:
- v*.*.*
jobs:
release:
name: Create release
runs-on: ubuntu-20.04
steps:
- name: Set variables
id: init
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
echo ::set-output name=version::${GITHUB_REF#refs/tags/v}
- name: Checkout
uses: actions/checkout@v2
- name: Write release body
id: body
run: |
FILENAME=RELEASE.md
extras/scripts/get-release-body.sh ${{ steps.init.outputs.tag }} CHANGELOG.md | tee $FILENAME
echo ::set-output name=filename::$FILENAME
- name: Amalgamate ArduinoJson.h
id: amalgamate_h
run: |
FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.h
extras/scripts/build-single-header.sh src/ArduinoJson.h "$FILENAME"
echo ::set-output name=filename::$FILENAME
- name: Amalgamate ArduinoJson.hpp
id: amalgamate_hpp
run: |
FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.hpp
extras/scripts/build-single-header.sh src/ArduinoJson.hpp "$FILENAME"
echo ::set-output name=filename::$FILENAME
- name: Create Arduino package
id: arduino
run: |
FILENAME=ArduinoJson-${{ steps.init.outputs.tag }}.zip
extras/scripts/build-arduino-package.sh . "$FILENAME"
echo ::set-output name=filename::$FILENAME
- name: Create release
uses: ncipollo/release-action@v1
with:
bodyFile: ${{ steps.body.outputs.filename }}
draft: true
name: ArduinoJson ${{ steps.init.outputs.version }}
artifacts: ${{ steps.amalgamate_h.outputs.filename }},${{ steps.amalgamate_hpp.outputs.filename }},${{ steps.arduino.outputs.filename }}
token: ${{ secrets.GITHUB_TOKEN }}

4
.gitignore vendored
View File

@ -10,3 +10,7 @@
/extras/fuzzing/*_fuzzer.options
/extras/fuzzing/*_fuzzer_seed_corpus.zip
.vs/
# Used by CI for Particle
/src/*.ino
/project.properties

View File

@ -1,6 +1,3 @@
.github/
examples/
fuzzing/
scripts/
test/
third-party/
extras/

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
*.md

View File

@ -1,136 +0,0 @@
sudo: false
language: cpp
matrix:
include:
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.4']
env: SCRIPT=test _CC=gcc-4.4 _CXX=g++-4.4
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.6']
env: SCRIPT=test _CC=gcc-4.6 _CXX=g++-4.6
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.7']
env: SCRIPT=test _CC=gcc-4.7 _CXX=g++-4.7
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8']
env: SCRIPT=test _CC=gcc-4.8 _CXX=g++-4.8 SANITIZE=address
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9']
env: SCRIPT=test _CC=gcc-4.9 _CXX=g++-4.9 SANITIZE=leak
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
env: SCRIPT=test _CC=gcc-5 _CXX=g++-5 # SANITIZE=undefined
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-6']
env: SCRIPT=test _CC=gcc-6 _CXX=g++-6
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-7']
env: SCRIPT=test _CC=gcc-7 _CXX=g++-7
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-8']
env: SCRIPT=test _CC=gcc-8 _CXX=g++-8
- addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-9']
env: SCRIPT=test _CC=gcc-9 _CXX=g++-9
- addons:
apt:
packages: ['g++-arm-linux-gnueabihf']
env: SCRIPT=build _CC=arm-linux-gnueabihf-gcc _CXX=arm-linux-gnueabihf-g++
- env: SCRIPT=test _CC=clang _CXX=clang++
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5']
packages: ['clang-3.5']
env: SCRIPT=test _CC=clang-3.5 _CXX=clang++-3.5 SANITIZE=address
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.6']
packages: ['clang-3.6']
env: SCRIPT=test _CC=clang-3.6 _CXX=clang++-3.6 SANITIZE=leak
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.7']
packages: ['clang-3.7']
env: SCRIPT=test _CC=clang-3.7 _CXX=clang++-3.7
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8']
packages: ['clang-3.8']
env: SCRIPT=test _CC=clang-3.8 _CXX=clang++-3.8 SANITIZE=undefined
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-3.9']
packages: ['clang-3.9']
env: SCRIPT=test _CC=clang-3.9 _CXX=clang++-3.9
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-4.0']
packages: ['clang-4.0']
env: SCRIPT=test _CC=clang-4.0 _CXX=clang++-4.0
- addons:
apt:
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']
packages: ['clang-6.0']
env: SCRIPT=test _CC=clang-6.0 _CXX=clang++-6.0
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-7']
packages: ['clang-7']
env: SCRIPT=test _CC=clang-7 _CXX=clang++-7
- addons:
apt:
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-8']
packages: ['clang-8']
env: SCRIPT=test _CC=clang-8 _CXX=clang++-8
- addons:
apt:
sources:
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages: ['clang-9']
env: SCRIPT=test _CC=clang-9 _CXX=clang++-9
- env: SCRIPT=coverage
- os: osx
osx_image: xcode8.3
env: SCRIPT=test
- os: osx
osx_image: xcode9.4
env: SCRIPT=test
- os: osx
osx_image: xcode10
env: SCRIPT=test SANITIZE=address
- env: SCRIPT=arduino VERSION=1.6.7 BOARD=arduino:avr:uno
- env: SCRIPT=arduino VERSION=1.8.2 BOARD=arduino:samd:mkr1000
- env: SCRIPT=platformio BOARD=uno
- env: SCRIPT=platformio BOARD=esp01
cache:
directories:
- "~/.platformio"
- "extras/fuzzing/json_corpus"
- "extras/fuzzing/msgpack_corpus"
script: extras/ci/$SCRIPT.sh

19
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.generator": "Ninja",
"git.inputValidationLength": 80,
"git.inputValidationSubjectLength": 72,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.associations": {
"fstream": "cpp",
"iomanip": "cpp",
"string": "cpp",
"system_error": "cpp",
"vector": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xstring": "cpp"
}
}

View File

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

View File

@ -1,6 +1,155 @@
ArduinoJson: change log
=======================
v6.18.4 (2021-09-06)
-------
* Fixed error `'dummy' may be used uninitialized` on GCC 11
* Fixed error `expected unqualified-id before 'const'` on GCC 11 (issue #1622)
* Filter: exact match takes precedence over wildcard (issue #1628)
* Fixed deserialization of `\u0000` (issue #1646)
v6.18.3 (2021-07-27)
-------
* Changed return type of `convertToJson()` and `Converter<T>::toJson()` to `void`
* Added `as<std::string_view>()` and `is<std::string_view>()`
v6.18.2 (2021-07-19)
-------
* Removed a symlink because the Arduino Library Specification forbids it
v6.18.1 (2021-07-03)
-------
* Fixed support for `volatile float` and `volatile double` (issue #1557)
* Fixed error `[Pe070]: incomplete type is not allowed` on IAR (issue #1560)
* Fixed `serializeJson(doc, String)` when allocation fails (issue #1572)
* Fixed clang-tidy warnings (issue #1574, PR #1577 by @armandas)
* Added fake class `InvalidConversion<T1,T2>` to easily identify invalid conversions (issue #1585)
* Added support for `std::string_view` (issue #1578, PR #1554 by @0xFEEDC0DE64)
* Fixed warning `definition of implicit copy constructor for 'MsgPackDeserializer' is deprecated because it has a user-declared copy assignment operator`
* Added `JsonArray::clear()` (issue #1597)
* Fixed `JsonVariant::as<unsigned>()` (issue #1601)
* Added support for ESP-IDF component build (PR #1562 by @qt1, PR #1599 by @andreaskuster)
v6.18.0 (2021-05-05)
-------
* Added support for custom converters (issue #687)
* Added support for `Printable` (issue #1444)
* Removed support for `char` values, see below (issue #1498)
* `deserializeJson()` leaves `\uXXXX` unchanged instead of returning `NotSupported`
* `deserializeMsgPack()` inserts `null` instead of returning `NotSupported`
* Removed `DeserializationError::NotSupported`
* Added `JsonVariant::is<JsonArrayConst/JsonObjectConst>()` (issue #1412)
* Added `JsonVariant::is<JsonVariant/JsonVariantConst>()` (issue #1412)
* Changed `JsonVariantConst::is<JsonArray/JsonObject>()` to return `false` (issue #1412)
* Simplified `JsonVariant::as<T>()` to always return `T` (see below)
* Updated folders list in `.mbedignore` (PR #1515 by @AGlass0fMilk)
* Fixed member-call-on-null-pointer in `getMember()` when array is empty
* `serializeMsgPack(doc, buffer, size)` doesn't add null-terminator anymore (issue #1545)
* `serializeJson(doc, buffer, size)` adds null-terminator only if there is enough room
* PlatformIO: set `build.libArchive` to `false` (PR #1550 by @askreet)
> ### BREAKING CHANGES
>
> #### Support for `char` removed
>
> We cannot cast a `JsonVariant` to a `char` anymore, so the following will break:
> ```c++
> char age = doc["age"]; // error: no matching function for call to 'variantAs(VariantData*&)'
> ```
> Instead, you must use another integral type, such as `int8_t`:
> ```c++
> int8_t age = doc["age"]; // OK
> ```
>
> Similarly, we cannot assign from a `char` anymore, so the following will break:
> ```c++
> char age;
> doc["age"] = age; // error: no matching function for call to 'VariantRef::set(const char&)'
> ```
> Instead, you must use another integral type, such as `int8_t`:
> ```c++
> int8_t age;
> doc["age"] = age; // OK
> ```
> A deprecation warning with the message "Support for `char` is deprecated, use `int8_t` or `uint8_t` instead" was added to allow a smooth transition.
>
> #### `as<T>()` always returns `T`
>
> Previously, `JsonVariant::as<T>()` could return a type different from `T`.
> The most common example is `as<char*>()` that returned a `const char*`.
> While this feature simplified a few use cases, it was confusing and complicated the
> implementation of custom converters.
>
> Starting from this version, `as<T>` doesn't try to auto-correct the return type and always return `T`,
> which means that you cannot write this anymore:
>
> ```c++
> Serial.println(doc["sensor"].as<char*>()); // error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
> ```
>
> Instead, you must write:
>
> ```c++
> Serial.println(doc["sensor"].as<const char*>()); // OK
> ```
>
> A deprecation warning with the message "Replace `as<char*>()` with `as<const char*>()`" was added to allow a smooth transition.
>
> #### `DeserializationError::NotSupported` removed
>
> On a different topic, `DeserializationError::NotSupported` has been removed.
> Instead of returning this error:
>
> * `deserializeJson()` leaves `\uXXXX` unchanged (only when `ARDUINOJSON_DECODE_UNICODE` is `0`)
> * `deserializeMsgPack()` replaces unsupported values with `null`s
>
> #### Const-aware `is<T>()`
>
> Lastly, a very minor change concerns `JsonVariantConst::is<T>()`.
> It used to return `true` for `JsonArray` and `JsonOject`, but now it returns `false`.
> Instead, you must use `JsonArrayConst` and `JsonObjectConst`.
v6.17.3 (2021-02-15)
-------
* Made `JsonDocument`'s destructor protected (issue #1480)
* Added missing calls to `client.stop()` in `JsonHttpClient.ino` (issue #1485)
* Fixed error `expected ')' before 'char'` when `isdigit()` is a macro (issue #1487)
* Fixed error `definition of implicit copy constructor is deprecated` on Clang 10
* PlatformIO: set framework compatibility to `*` (PR #1490 by @maxgerhardt)
v6.17.2 (2020-11-14)
-------
* Fixed invalid conversion error in `operator|(JsonVariant, char*)` (issue #1432)
* Changed the default value of `ARDUINOJSON_ENABLE_PROGMEM` (issue #1433).
It now checks that the `pgm_read_XXX` macros are defined before enabling `PROGMEM`.
v6.17.1 (2020-11-07)
-------
* Fixed error `ambiguous overload for 'operator|'` (issue #1411)
* Fixed `operator|(MemberProxy, JsonObject)` (issue #1415)
* Allowed more than 32767 values in non-embedded mode (issue #1414)
v6.17.0 (2020-10-19)
-------
* Added a build failure when nullptr is defined as a macro (issue #1355)
* Added `JsonDocument::overflowed()` which tells if the memory pool was too small (issue #1358)
* Added `DeserializationError::EmptyInput` which tells if the input was empty
* Added `DeserializationError::f_str()` which returns a `const __FlashStringHelper*` (issue #846)
* Added `operator|(JsonVariantConst, JsonVariantConst)`
* Added filtering for MessagePack (issue #1298, PR #1394 by Luca Passarella)
* Moved float convertion tables to PROGMEM
* Fixed `JsonVariant::set((char*)0)` which returned false instead of true (issue #1368)
* Fixed error `No such file or directory #include <WString.h>` (issue #1381)
v6.16.1 (2020-08-04)
-------
@ -12,6 +161,7 @@ v6.16.0 (2020-08-01)
* Added comparisons (`>`, `>=`, `==`, `!=`, `<`, and `<=`) between `JsonVariant`s
* Added string deduplication (issue #1303)
* Added `JsonString::operator!=`
* Added wildcard key (`*`) for filters (issue #1309)
* Set `ARDUINOJSON_DECODE_UNICODE` to `1` by default
* Fixed `copyArray()` not working with `String`, `ElementProxy`, and `MemberProxy`
* Fixed error `getOrAddElement is not a member of ElementProxy` (issue #1311)

View File

@ -1,10 +1,17 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2020
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.3)
project(ArduinoJson VERSION 6.16.1)
if(ESP_PLATFORM)
# Build ArduinoJson as an ESP-IDF component
idf_component_register(INCLUDE_DIRS src)
target_compile_definitions(${COMPONENT_LIB} INTERFACE ARDUINOJSON_EMBEDDED_MODE=1)
return()
endif()
project(ArduinoJson VERSION 6.18.4)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)

View File

@ -6,6 +6,5 @@ You can submit changes via GitHub Pull Requests.
Please:
1. Unit test every change in behavior
1. Update the test suite for any change of behavior
2. Use clang-format in "file" mode to format the code
3. Consider using the Continuous Integration (Travis and AppVeyor)

View File

@ -1,7 +1,7 @@
The MIT License (MIT)
---------------------
Copyright © 2014-2020 Benoit BLANCHON
Copyright © 2014-2021 Benoit BLANCHON
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -2,9 +2,9 @@
---
[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.16.1)](https://www.ardu-badge.com/ArduinoJson/6.16.1)
[![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)
[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.18.4)](https://www.ardu-badge.com/ArduinoJson/6.18.4)
[![Continuous Integration](https://github.com/bblanchon/ArduinoJson/workflows/Continuous%20Integration/badge.svg?branch=6.x)](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x)
[![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
[![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)
[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat)](https://github.com/bblanchon/ArduinoJson/stargazers)
@ -19,7 +19,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* [Optionally supports comments in the input](https://arduinojson.org/v6/api/config/enable_comments/?utm_source=github&utm_medium=readme)
* [Optionally filters the input to keep only desired values](https://arduinojson.org/v6/api/json/deserializejson/?utm_source=github&utm_medium=readme#filtering)
* Supports single quotes as a string delimiter
* Compatible with NDJSON and JSON Lines
* Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/)
* [JSON serialization](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme)
* [Can write to a buffer or a stream](https://arduinojson.org/v6/api/json/serializejson/?utm_source=github&utm_medium=readme)
* [Optionally indents the document (prettified JSON)](https://arduinojson.org/v6/api/json/serializejsonpretty/?utm_source=github&utm_medium=readme)
@ -33,14 +33,15 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/?utm_source=github&utm_medium=readme)
* Deduplicates strings
* Versatile
* [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)
* 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 Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme)
* 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)
* Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/?utm_source=github&utm_medium=readme), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/?utm_source=github&utm_medium=readme) and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/?utm_source=github&utm_medium=readme)
* Supports [`Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/?utm_source=github&utm_medium=readme) and [`std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/?utm_source=github&utm_medium=readme)
* Supports [Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/?utm_source=github&utm_medium=readme)
* 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)
* Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/?utm_source=github&utm_medium=readme)
* Portable
* Usable on any C++ project (not limited to Arduino)
* Compatible with C++98
* Compatible with C++98, C++11, C++14 and C++17
* Zero warnings with `-Wall -Wextra -pedantic` and `/W4`
* [Header-only library](https://en.wikipedia.org/wiki/Header-only)
* Works with virtually any board
@ -58,11 +59,12 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* [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)
* [Particle](https://www.particle.io/)
* [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)
* [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN)
* [CMake friendly](https://arduinojson.org/v6/how-to/use-arduinojson-with-cmake/?utm_source=github&utm_medium=readme)
* Well designed
* [Elegant API](http://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme)
@ -76,17 +78,20 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
* [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)
* [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
* [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)
* [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
* Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/)
* Well documented
* [Tutorials](https://arduinojson.org/v6/doc/deserialization/?utm_source=github&utm_medium=readme)
* [Examples](https://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme)
* [How-tos](https://arduinojson.org/v6/example/?utm_source=github&utm_medium=readme)
* [FAQ](https://arduinojson.org/v6/faq/?utm_source=github&utm_medium=readme)
* [Troubleshooter](https://arduinojson.org/v6/troubleshooter/?utm_source=github&utm_medium=readme)
* [Book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme)
* [Changelog](CHANGELOG.md)
* 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)
* Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories)
* [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)
@ -129,9 +134,11 @@ serializeJson(doc, Serial);
See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme)
## Support the project
## Support the project ❤️
Do you like this library? Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)!
Do you like this library?
Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)!
What? You don't like it but you *love* it?
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.
You can support the project by [purchasing my book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme).
Alternatively, you can make a recurring donation via [GitHub Sponsors](https://github.com/sponsors/bblanchon).

View File

@ -1,4 +1,4 @@
version: 6.16.1.{build}
version: 6.18.4.{build}
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to store your project configuration in a file.
@ -44,7 +44,7 @@ void loadConfiguration(const char *filename, Config &config) {
// Allocate a temporary JsonDocument
// Don't forget to change the capacity to match your requirements.
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<512> doc;
// Deserialize the JSON document
@ -76,7 +76,7 @@ void saveConfiguration(const char *filename, const Config &config) {
// Allocate a temporary JsonDocument
// Don't forget to change the capacity to match your requirements.
// Use arduinojson.org/assistant to compute the capacity.
// Use https://arduinojson.org/assistant to compute the capacity.
StaticJsonDocument<256> doc;
// Set the values in the document
@ -140,6 +140,12 @@ void loop() {
// not used in this example
}
// Performance issue?
// ------------------
//
// File is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See also
// --------
//

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to use DeserializationOpion::Filter

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.
@ -17,7 +17,7 @@ void setup() {
//
// Inside the brackets, 200 is the RAM allocated to this document.
// Don't forget to change this value to match your requirement.
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<200> doc;
// StaticJsonObject allocates memory on the stack, it can be

View File

@ -1,11 +1,11 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to parse a JSON document in an HTTP response.
// It uses the Ethernet library, but can be easily adapted for Wifi.
//
// It performs a GET resquest on arduinojson.org/example.json
// It performs a GET resquest on https://arduinojson.org/example.json
// Here is the expected response:
// {
// "sensor": "gps",
@ -53,6 +53,7 @@ void setup() {
client.println(F("Connection: close"));
if (client.println() == 0) {
Serial.println(F("Failed to send request"));
client.stop();
return;
}
@ -63,6 +64,7 @@ void setup() {
if (strcmp(status + 9, "200 OK") != 0) {
Serial.print(F("Unexpected response: "));
Serial.println(status);
client.stop();
return;
}
@ -70,11 +72,12 @@ void setup() {
char endOfHeaders[] = "\r\n\r\n";
if (!client.find(endOfHeaders)) {
Serial.println(F("Invalid response"));
client.stop();
return;
}
// Allocate the JSON document
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;
DynamicJsonDocument doc(capacity);
@ -82,13 +85,14 @@ void setup() {
DeserializationError error = deserializeJson(doc, client);
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.c_str());
Serial.println(error.f_str());
client.stop();
return;
}
// Extract values
Serial.println(F("Response:"));
Serial.println(doc["sensor"].as<char*>());
Serial.println(doc["sensor"].as<const char*>());
Serial.println(doc["time"].as<long>());
Serial.println(doc["data"][0].as<float>(), 6);
Serial.println(doc["data"][1].as<float>(), 6);
@ -101,6 +105,12 @@ void loop() {
// not used in this example
}
// Performance issue?
// ------------------
//
// EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See also
// --------
//

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to deserialize a JSON document with ArduinoJson.
@ -17,7 +17,7 @@ void setup() {
//
// Inside the brackets, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<200> doc;
// StaticJsonDocument<N> allocates memory on the stack, it can be
@ -42,7 +42,7 @@ void setup() {
// Test if parsing succeeds.
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.c_str());
Serial.println(error.f_str());
return;
}

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to implement an HTTP server that sends a JSON document
@ -46,7 +46,8 @@ void loop() {
EthernetClient client = server.available();
// Do we have a client?
if (!client) return;
if (!client)
return;
Serial.println(F("New client"));
@ -54,7 +55,7 @@ void loop() {
while (client.available()) client.read();
// Allocate a temporary JsonDocument
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<500> doc;
// Create the "analog" array
@ -96,6 +97,12 @@ void loop() {
client.stop();
}
// Performance issue?
// ------------------
//
// EthernetClient is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See also
// --------
//

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to send a JSON document to a UDP socket.
@ -46,7 +46,7 @@ void setup() {
void loop() {
// Allocate a temporary JsonDocument
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<500> doc;
// Create the "analog" array
@ -86,6 +86,12 @@ void loop() {
delay(10000);
}
// Performance issue?
// ------------------
//
// EthernetUDP is an unbuffered stream, which is not optimal for ArduinoJson.
// See: https://arduinojson.org/v6/how-to/improve-speed/
// See also
// --------
//

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to deserialize a MessagePack document with
@ -18,7 +18,7 @@ void setup() {
//
// Inside the brackets, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<200> doc;
// StaticJsonObject allocates memory on the stack, it can be
@ -50,7 +50,7 @@ void setup() {
// Test if parsing succeeded.
if (error) {
Serial.print("deserializeMsgPack() failed: ");
Serial.println(error.c_str());
Serial.println(error.f_str());
return;
}

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// 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-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows the different ways you can use String with ArduinoJson.

View File

@ -23,12 +23,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
-Wundef
)
if(NOT MINGW)
add_compile_options(
-std=c++98
)
endif()
if(${COVERAGE})
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage")
endif()
@ -36,7 +30,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8)
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8) AND (NOT ${COVERAGE}))
add_compile_options(-g -Og)
else()
add_compile_options(-g -O0)
@ -70,7 +64,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0)
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0) AND (NOT ${COVERAGE}))
add_compile_options(-g -Og)
else()
add_compile_options(-g -O0)
@ -78,7 +72,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0) AND (NOT ${COVERAGE}))
add_compile_options(-g -Og)
else()
add_compile_options(-g -O0)

View File

@ -1,7 +0,0 @@
#!/bin/sh -ex
export CC="$_CC"
export CXX="$_CXX"
cmake -DCMAKE_BUILD_TYPE=Release .
cmake --build .

View File

@ -1,9 +0,0 @@
#!/bin/sh -eux
cmake -DCOVERAGE=true .
make
make test
pip install --user cpp-coveralls 'requests[security]'
pwd
coveralls --include 'src' --gcov-options '\-lp'

View File

@ -0,0 +1,8 @@
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(example)

View File

@ -0,0 +1,6 @@
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
idf_component_register(SRCS "main.cpp"
INCLUDE_DIRS "")

View File

@ -0,0 +1,4 @@
#
# "main" pseudo-component makefile.
#
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)

View File

@ -0,0 +1,16 @@
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#include <ArduinoJson.h>
extern "C" void app_main() {
char buffer[256];
StaticJsonDocument<200> doc;
doc["hello"] = "world";
serializeJson(doc, buffer);
deserializeJson(doc, buffer);
serializeMsgPack(doc, buffer);
deserializeMsgPack(doc, buffer);
}

View File

@ -1,22 +0,0 @@
#!/bin/bash -eux
ROOT_DIR=$(dirname $0)/../../
FUZZING_DIR=${ROOT_DIR}/extras/fuzzing/
export CC="clang-${CLANG}"
export CXX="clang++-${CLANG}"
cmake -DCMAKE_BUILD_TYPE=Debug .
FUZZER_TARGET="${FUZZER}_fuzzer"
FUZZER_PATH="extras/fuzzing/${FUZZER_TARGET}"
CORPUS_DIR="${FUZZING_DIR}/${FUZZER}_corpus"
SEED_CORPUS_DIR="${FUZZING_DIR}/${FUZZER}_seed_corpus"
cmake --build . --target $FUZZER_TARGET
export ASAN_OPTIONS="detect_leaks=0"
export LLVM_PROFILE_FILE="${FUZZER_TARGET}.profraw"
${FUZZER_PATH} "$CORPUS_DIR" "$SEED_CORPUS_DIR" -max_total_time=60 -timeout=1
llvm-profdata-${CLANG} merge -sparse ${LLVM_PROFILE_FILE} -o ${FUZZER_TARGET}.profdata
llvm-cov-${CLANG} report ./${FUZZER_PATH} -instr-profile=${FUZZER_TARGET}.profdata

10
extras/ci/particle.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh -ex
BOARD=$1
cd "$(dirname "$0")/../../"
cp extras/particle/src/smocktest.ino src/
cp extras/particle/project.properties ./
particle compile "$BOARD"

View File

@ -1,20 +0,0 @@
#!/bin/sh -eux
pip install --user platformio
case $BOARD in
uno)
platformio lib install 868 # SD library
platformio lib install 872 # Ethernet library
;;
esp01)
platformio lib uninstall 161 || true
platformio lib uninstall 868 || true
platformio lib uninstall 872 || true
;;
esac
for EXAMPLE in $PWD/examples/*/*.ino;
do
platformio ci $EXAMPLE -l '.' -b $BOARD
done

View File

@ -1,10 +0,0 @@
#!/bin/sh -ex
export CC="$_CC"
export CXX="$_CXX"
[ -n "$SANITIZE" ] && export CXXFLAGS="-fsanitize=$SANITIZE"
cmake -DCMAKE_BUILD_TYPE=Debug .
cmake --build .
ctest --output-on-failure .

View File

@ -1,5 +1,5 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2020
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
if(MSVC)
@ -22,11 +22,8 @@ target_link_libraries(json_reproducer
ArduinoJson
)
# Infer path of llvm-symbolizer from the path of clang
string(REPLACE "clang++" "llvm-symbolizer" LLVM_SYMBOLIZER ${CMAKE_CXX_COMPILER})
macro(add_fuzzer name mode)
set(FUZZER "${name}_${mode}_fuzzer")
macro(add_fuzzer name)
set(FUZZER "${name}_fuzzer")
set(CORPUS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${name}_corpus")
set(SEED_CORPUS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${name}_seed_corpus")
add_executable("${FUZZER}"
@ -38,9 +35,9 @@ macro(add_fuzzer name mode)
set_target_properties("${FUZZER}"
PROPERTIES
COMPILE_FLAGS
"-fprofile-instr-generate -fcoverage-mapping -fsanitize=${mode},fuzzer -fno-sanitize-recover=all"
"-fprofile-instr-generate -fcoverage-mapping -fsanitize=fuzzer -fno-sanitize-recover=all"
LINK_FLAGS
"-fprofile-instr-generate -fcoverage-mapping -fsanitize=${mode},fuzzer -fno-sanitize-recover=all"
"-fprofile-instr-generate -fcoverage-mapping -fsanitize=fuzzer -fno-sanitize-recover=all"
)
add_test(
@ -52,22 +49,11 @@ macro(add_fuzzer name mode)
set_tests_properties("${FUZZER}"
PROPERTIES
ENVIRONMENT
ASAN_SYMBOLIZER_PATH=${LLVM_SYMBOLIZER}
ENVIRONMENT
LLVM_SYMBOLIZER_PATH=${LLVM_SYMBOLIZER}
ENVIRONMENT
MSAN_SYMBOLIZER_PATH=${LLVM_SYMBOLIZER}
ENVIRONMENT
UBSAN_SYMBOLIZER_PATH=${LLVM_SYMBOLIZER}
LABELS "Fuzzing"
)
endmacro()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6)
add_fuzzer(json address)
add_fuzzer(json memory)
add_fuzzer(json undefined)
add_fuzzer(msgpack address)
add_fuzzer(msgpack memory)
add_fuzzer(msgpack undefined)
add_fuzzer(json)
add_fuzzer(msgpack)
endif()

View File

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

View File

@ -0,0 +1 @@
name=ArduinoJsonCI

View File

@ -0,0 +1,5 @@
#include "ArduinoJson.h"
void setup() {}
void loop() {}

View File

@ -1,21 +1,23 @@
#!/bin/bash
TAG=$(git describe)
OUTPUT="ArduinoJson-$TAG.zip"
set -eu
cd $(dirname $0)/../../..
INPUT=$1
OUTPUT=$2
cd "$INPUT"
# remove existing file
rm -f $OUTPUT
rm -f "$OUTPUT"
# create zip
7z a $OUTPUT \
-xr!.vs \
ArduinoJson/CHANGELOG.md \
ArduinoJson/examples \
ArduinoJson/src \
ArduinoJson/keywords.txt \
ArduinoJson/library.properties \
ArduinoJson/LICENSE.md \
ArduinoJson/README.md \
ArduinoJson/ArduinoJson.h
7z a "$OUTPUT" \
-xr!.vs \
CHANGELOG.md \
examples \
src \
keywords.txt \
library.properties \
LICENSE.md \
README.md \
ArduinoJson.h

View File

@ -2,11 +2,10 @@
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:]]*(//.*)?$'
RE_RELATIVE_INCLUDE='^#[[:space:]]*include[[:space:]]*"(.*)"'
RE_ABSOLUTE_INCLUDE='^#[[:space:]]*include[[:space:]]*<(ArduinoJson/.*)>'
RE_SYSTEM_INCLUDE='^#[[:space:]]*include[[:space:]]*<(.*)>'
RE_EMPTY='^(#[[:space:]]*pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
SRC_DIRECTORY="$(realpath "$(dirname $0)/../../src")"
@ -58,25 +57,8 @@ simplify_namespaces() {
rm -f "$1.bak"
}
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
INPUT=$1
OUTPUT=$2
process "$INPUT" true > "$OUTPUT"
simplify_namespaces "$OUTPUT"

View File

@ -0,0 +1,14 @@
#!/bin/bash
set -eu
TAG="$1"
CHANGELOG="$2"
cat << END
## Changes
$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG")
[View version history](https://github.com/bblanchon/ArduinoJson/blob/$TAG/CHANGELOG.md)
END

View File

@ -0,0 +1,18 @@
#!/bin/bash
set -eu
VERSION="$1"
CHANGELOG="$2"
FRONTMATTER="$3"
cat << END
---
branch: v6
version: $VERSION
date: '$(date +'%Y-%m-%d')'
$(cat "$FRONTMATTER")
---
$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' "$CHANGELOG")
END

View File

@ -59,6 +59,10 @@ commit_new_version
add_tag
push
extras/scripts/build-arduino-package.sh
extras/scripts/build-single-header.sh
extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h"
extras/scripts/build-arduino-package.sh . "../ArduinoJson-$TAG.zip"
extras/scripts/build-single-header.sh "src/ArduinoJson.h" "../ArduinoJson-$TAG.h"
extras/scripts/build-single-header.sh "src/ArduinoJson.hpp" "../ArduinoJson-$TAG.hpp"
extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h" > "../ArduinoJson-$TAG-wandbox.txt"
extras/scripts/get-release-page.sh "$VERSION" "CHANGELOG.md" "../ArduinoJson-$TAG-wandbox.txt" > "../ArduinoJson-$TAG.md"
echo "You can now copy ../ArduinoJson-$TAG.md into arduinojson.org/collections/_versions/$VERSION.md"

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.
@ -12,7 +12,7 @@ int main() {
//
// Inside the brackets, 200 is the RAM allocated to this document.
// Don't forget to change this value to match your requirement.
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<200> doc;
// StaticJsonObject allocates memory on the stack, it can be

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to deserialize a JSON document with ArduinoJson.
@ -12,7 +12,7 @@ int main() {
//
// Inside the brackets, 200 is the capacity of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use arduinojson.org/v6/assistant to compute the capacity.
// Use https://arduinojson.org/v6/assistant to compute the capacity.
StaticJsonDocument<300> doc;
// StaticJsonDocument<N> allocates memory on the stack, it can be

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
//
// This example shows how to generate a JSON document with ArduinoJson.
@ -12,7 +12,7 @@ int main() {
//
// Inside the brackets, 300 is the size of the memory pool in bytes.
// Don't forget to change this value to match your JSON document.
// Use arduinojson.org/assistant to compute the capacity.
// Use https://arduinojson.org/assistant to compute the capacity.
StaticJsonDocument<300> doc;
// StaticJsonObject allocates memory on the stack, it can be

View File

@ -21,7 +21,7 @@ compile() {
END
URL=$(curl -sS -H "Content-type: application/json" -d @parameters.json https://wandbox.org/api/compile.json | jq --raw-output .url)
rm parameters.json
echo " $1: $URL"
echo "$1: $URL"
}
compile "JsonGeneratorExample"

1
extras/tests/.clang-tidy Normal file
View File

@ -0,0 +1 @@
Checks: '-clang-analyzer-security.insecureAPI.*'

View File

@ -1,13 +1,18 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2020
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(catch)
link_libraries(ArduinoJson catch)
include_directories(Helpers)
add_subdirectory(ElementProxy)
add_subdirectory(Cpp11)
add_subdirectory(Cpp17)
add_subdirectory(Cpp20)
add_subdirectory(FailingBuilds)
add_subdirectory(IntegrationTests)
add_subdirectory(JsonArray)
@ -16,7 +21,6 @@ add_subdirectory(JsonDocument)
add_subdirectory(JsonObject)
add_subdirectory(JsonSerializer)
add_subdirectory(JsonVariant)
add_subdirectory(MemberProxy)
add_subdirectory(MemoryPool)
add_subdirectory(Misc)
add_subdirectory(MixedConfiguration)

View File

@ -0,0 +1,32 @@
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
if("cxx_nullptr" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
list(APPEND SOURCES nullptr.cpp)
add_definitions(-DARDUINOJSON_HAS_NULLPTR=1)
endif()
if("cxx_auto_type" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND "cxx_constexpr" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
list(APPEND SOURCES issue1120.cpp)
endif()
if("cxx_long_long_type" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
list(APPEND SOURCES use_long_long_0.cpp use_long_long_1.cpp)
endif()
if(NOT SOURCES)
return()
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(Cpp11Tests ${SOURCES})
add_test(Cpp11 Cpp11Tests)
set_tests_properties(Cpp11
PROPERTIES
LABELS "Catch"
)

View File

@ -2,40 +2,6 @@
#include <catch.hpp>
#if __cplusplus >= 201103L
TEST_CASE("nullptr") {
DynamicJsonDocument doc(4096);
JsonVariant variant = doc.to<JsonVariant>();
SECTION("JsonVariant == nullptr") {
REQUIRE((variant == nullptr));
REQUIRE_FALSE((variant != nullptr));
}
SECTION("JsonVariant != nullptr") {
variant.set(42);
REQUIRE_FALSE((variant == nullptr));
REQUIRE((variant != nullptr));
}
SECTION("JsonVariant.set(nullptr)") {
variant.set(42);
variant.set(nullptr);
REQUIRE(variant.isNull());
}
SECTION("JsonVariant.is<nullptr_t>()") {
variant.set(42);
REQUIRE(variant.is<std::nullptr_t>() == false);
variant.clear();
REQUIRE(variant.is<std::nullptr_t>() == true);
}
}
TEST_CASE("Issue #1120") {
StaticJsonDocument<500> doc;
constexpr char str[] =
@ -90,5 +56,3 @@ TEST_CASE("Issue #1120") {
}
}
}
#endif

View File

@ -0,0 +1,39 @@
#include <ArduinoJson.h>
#include <catch.hpp>
#if !ARDUINOJSON_HAS_NULLPTR
# error ARDUINOJSON_HAS_NULLPTR must be set to 1
#endif
TEST_CASE("nullptr") {
DynamicJsonDocument doc(4096);
JsonVariant variant = doc.to<JsonVariant>();
SECTION("JsonVariant == nullptr") {
REQUIRE((variant == nullptr));
REQUIRE_FALSE((variant != nullptr));
}
SECTION("JsonVariant != nullptr") {
variant.set(42);
REQUIRE_FALSE((variant == nullptr));
REQUIRE((variant != nullptr));
}
SECTION("JsonVariant.set(nullptr)") {
variant.set(42);
variant.set(nullptr);
REQUIRE(variant.isNull());
}
SECTION("JsonVariant.is<nullptr_t>()") {
variant.set(42);
REQUIRE(variant.is<std::nullptr_t>() == false);
variant.clear();
REQUIRE(variant.is<std::nullptr_t>() == true);
}
}

View File

@ -0,0 +1,29 @@
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
if(MSVC_VERSION LESS 1910)
return()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
return()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7)
return()
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(Cpp17Tests
string_view.cpp
)
add_test(Cpp17 Cpp17Tests)
set_tests_properties(Cpp17
PROPERTIES
LABELS "Catch"
)

View File

@ -0,0 +1,89 @@
#include <ArduinoJson.h>
#include <catch.hpp>
#include <string_view>
#if !ARDUINOJSON_ENABLE_STRING_VIEW
# error ARDUINOJSON_ENABLE_STRING_VIEW must be set to 1
#endif
TEST_CASE("string_view") {
StaticJsonDocument<128> doc;
JsonVariant variant = doc.to<JsonVariant>();
SECTION("deserializeJson()") {
auto err = deserializeJson(doc, std::string_view("123", 2));
REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc.as<int>() == 12);
}
SECTION("JsonDocument::set()") {
doc.set(std::string_view("123", 2));
REQUIRE(doc.as<std::string>() == "12");
}
SECTION("JsonDocument::operator[]() const") {
doc["ab"] = "Yes";
doc["abc"] = "No";
REQUIRE(doc[std::string_view("abc", 2)] == "Yes");
}
SECTION("JsonDocument::operator[]()") {
doc[std::string_view("abc", 2)] = "Yes";
REQUIRE(doc["ab"] == "Yes");
}
SECTION("JsonVariant::operator==()") {
variant.set("A");
REQUIRE(variant == std::string_view("AX", 1));
REQUIRE_FALSE(variant == std::string_view("BX", 1));
}
SECTION("JsonVariant::operator>()") {
variant.set("B");
REQUIRE(variant > std::string_view("AX", 1));
REQUIRE_FALSE(variant > std::string_view("CX", 1));
}
SECTION("JsonVariant::operator<()") {
variant.set("B");
REQUIRE(variant < std::string_view("CX", 1));
REQUIRE_FALSE(variant < std::string_view("AX", 1));
}
SECTION("String deduplication") {
doc.add(std::string_view("example one", 7));
REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(1) + 8);
doc.add(std::string_view("example two", 7));
REQUIRE(doc.memoryUsage() == JSON_ARRAY_SIZE(2) + 8);
}
SECTION("as<std::string_view>()") {
doc["s"] = "Hello World";
doc["i"] = 42;
REQUIRE(doc["s"].as<std::string_view>() == std::string_view("Hello World"));
REQUIRE(doc["i"].as<std::string_view>() == std::string_view());
}
SECTION("is<std::string_view>()") {
doc["s"] = "Hello World";
doc["i"] = 42;
REQUIRE(doc["s"].is<std::string_view>() == true);
REQUIRE(doc["i"].is<std::string_view>() == false);
}
}
using ARDUINOJSON_NAMESPACE::adaptString;
TEST_CASE("StringViewAdapter") {
std::string_view str("bravoXXX", 5);
auto adapter = adaptString(str);
CHECK(adapter.compare(NULL) > 0);
CHECK(adapter.compare("alpha") > 0);
CHECK(adapter.compare("bravo") == 0);
CHECK(adapter.compare("charlie") < 0);
CHECK(adapter.size() == 5);
}

View File

@ -0,0 +1,29 @@
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
if(MSVC_VERSION LESS 1910)
return()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10)
return()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10)
return()
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(Cpp20Tests
smoke_test.cpp
)
add_test(Cpp20 Cpp20Tests)
set_tests_properties(Cpp20
PROPERTIES
LABELS "Catch"
)

View File

@ -0,0 +1,15 @@
#include <ArduinoJson.h>
#include <catch.hpp>
#include <string>
TEST_CASE("C++20 smoke test") {
StaticJsonDocument<128> doc;
deserializeJson(doc, "{\"hello\":\"world\"}");
REQUIRE(doc["hello"] == "world");
std::string json;
serializeJson(doc, json);
REQUIRE(json == "{\"hello\":\"world\"}");
}

View File

@ -1,15 +0,0 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2020
# MIT License
add_executable(ElementProxyTests
add.cpp
clear.cpp
compare.cpp
remove.cpp
set.cpp
size.cpp
subscript.cpp
)
add_test(ElementProxy ElementProxyTests)

View File

@ -1,34 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("ElementProxy::add()") {
DynamicJsonDocument doc(4096);
doc.addElement();
ElementProxy<JsonDocument&> ep = doc[0];
SECTION("add(int)") {
ep.add(42);
REQUIRE(doc.as<std::string>() == "[[42]]");
}
SECTION("add(const char*)") {
ep.add("world");
REQUIRE(doc.as<std::string>() == "[[\"world\"]]");
}
SECTION("set(char[])") {
char s[] = "world";
ep.add(s);
strcpy(s, "!!!!!");
REQUIRE(doc.as<std::string>() == "[[\"world\"]]");
}
}

View File

@ -1,28 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("ElementProxy::clear()") {
DynamicJsonDocument doc(4096);
doc.addElement();
ElementProxy<JsonDocument&> ep = doc[0];
SECTION("size goes back to zero") {
ep.add(42);
ep.clear();
REQUIRE(ep.size() == 0);
}
SECTION("isNull() return true") {
ep.add("hello");
ep.clear();
REQUIRE(ep.isNull() == true);
}
}

View File

@ -1,48 +0,0 @@
// 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("1 vs 1") {
doc.add(1);
doc.add(1);
REQUIRE(doc[0] <= doc[1]);
REQUIRE(doc[0] == doc[1]);
REQUIRE(doc[0] >= doc[1]);
REQUIRE_FALSE(doc[0] != doc[1]);
REQUIRE_FALSE(doc[0] < doc[1]);
REQUIRE_FALSE(doc[0] > doc[1]);
}
SECTION("1 vs 2") {
doc.add(1);
doc.add(2);
REQUIRE(doc[0] != doc[1]);
REQUIRE(doc[0] < doc[1]);
REQUIRE(doc[0] <= doc[1]);
REQUIRE_FALSE(doc[0] == doc[1]);
REQUIRE_FALSE(doc[0] > doc[1]);
REQUIRE_FALSE(doc[0] >= doc[1]);
}
SECTION("'abc' vs 'bcd'") {
doc.add("abc");
doc.add("bcd");
REQUIRE(doc[0] != doc[1]);
REQUIRE(doc[0] < doc[1]);
REQUIRE(doc[0] <= doc[1]);
REQUIRE_FALSE(doc[0] == doc[1]);
REQUIRE_FALSE(doc[0] > doc[1]);
REQUIRE_FALSE(doc[0] >= doc[1]);
}
}

View File

@ -1,56 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("ElementProxy::remove()") {
DynamicJsonDocument doc(4096);
doc.addElement();
ElementProxy<JsonDocument&> ep = doc[0];
SECTION("remove(int)") {
ep.add(1);
ep.add(2);
ep.add(3);
ep.remove(1);
REQUIRE(ep.as<std::string>() == "[1,3]");
}
SECTION("remove(const char *)") {
ep["a"] = 1;
ep["b"] = 2;
ep.remove("a");
REQUIRE(ep.as<std::string>() == "{\"b\":2}");
}
SECTION("remove(std::string)") {
ep["a"] = 1;
ep["b"] = 2;
ep.remove(std::string("b"));
REQUIRE(ep.as<std::string>() == "{\"a\":1}");
}
#ifdef HAS_VARIABLE_LENGTH_ARRAY
SECTION("remove(vla)") {
ep["a"] = 1;
ep["b"] = 2;
int i = 4;
char vla[i];
strcpy(vla, "b");
ep.remove(vla);
REQUIRE(ep.as<std::string>() == "{\"a\":1}");
}
#endif
}

View File

@ -1,33 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("ElementProxy::set()") {
DynamicJsonDocument doc(4096);
ElementProxy<JsonDocument&> ep = doc[0];
SECTION("set(int)") {
ep.set(42);
REQUIRE(doc.as<std::string>() == "[42]");
}
SECTION("set(const char*)") {
ep.set("world");
REQUIRE(doc.as<std::string>() == "[\"world\"]");
}
SECTION("set(char[])") {
char s[] = "world";
ep.set(s);
strcpy(s, "!!!!!");
REQUIRE(doc.as<std::string>() == "[\"world\"]");
}
}

View File

@ -1,30 +0,0 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
TEST_CASE("ElementProxy::size()") {
DynamicJsonDocument doc(4096);
doc.addElement();
ElementProxy<JsonDocument&> ep = doc[0];
SECTION("returns 0") {
REQUIRE(ep.size() == 0);
}
SECTION("as an array, returns 2") {
ep.add(1);
ep.add(2);
REQUIRE(ep.size() == 2);
}
SECTION("as an object, returns 2") {
ep["a"] = 1;
ep["b"] = 2;
REQUIRE(ep.size() == 2);
}
}

View File

@ -1,25 +0,0 @@
// 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);
ElementProxy<JsonDocument&> ep = doc[1];
SECTION("set member") {
ep["world"] = 42;
REQUIRE(doc.as<std::string>() == "[null,{\"world\":42}]");
}
SECTION("set element") {
ep[2] = 42;
REQUIRE(doc.as<std::string>() == "[null,[null,null,42]]");
}
}

View File

@ -1,5 +1,5 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2020
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
macro(build_should_fail target)
@ -18,7 +18,8 @@ macro(build_should_fail target)
)
set_tests_properties(${target}
PROPERTIES
WILL_FAIL TRUE
WILL_FAIL TRUE
LABELS "WillFail;Catch"
)
endmacro()
@ -36,3 +37,12 @@ build_should_fail(read_long_long)
add_executable(write_long_long write_long_long.cpp)
set_property(TARGET write_long_long PROPERTY CXX_STANDARD 11)
build_should_fail(write_long_long)
add_executable(delete_jsondocument delete_jsondocument.cpp)
build_should_fail(delete_jsondocument)
add_executable(variant_as_char variant_as_char.cpp)
build_should_fail(variant_as_char)
add_executable(assign_char assign_char.cpp)
build_should_fail(assign_char)

View File

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

View File

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

View File

@ -0,0 +1,12 @@
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#include <ArduinoJson.h>
// See issue #1498
int main() {
DynamicJsonDocument doc(1024);
doc["dummy"] = 'A';
}

View File

@ -0,0 +1,12 @@
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#include <ArduinoJson.h>
struct Stream {};
int main() {
JsonDocument* doc = new DynamicJsonDocument(42);
delete doc;
}

View File

@ -1,16 +1,16 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#define ARDUINOJSON_USE_LONG_LONG 0
#include <ArduinoJson.h>
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8
#error This test requires sizeof(long) < 8
# error This test requires sizeof(long) < 8
#endif
#if !ARDUINOJSON_HAS_LONG_LONG
#error This test requires C++11
# error This test requires C++11
#endif
ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(long long)

View File

@ -0,0 +1,12 @@
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#include <ArduinoJson.h>
// See issue #1498
int main() {
DynamicJsonDocument doc(1024);
doc["dummy"].as<char>();
}

View File

@ -1,16 +1,16 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#define ARDUINOJSON_USE_LONG_LONG 0
#include <ArduinoJson.h>
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8
#error This test requires sizeof(long) < 8
# error This test requires sizeof(long) < 8
#endif
#if !ARDUINOJSON_HAS_LONG_LONG
#error This test requires C++11
# error This test requires C++11
#endif
int main() {

View File

@ -0,0 +1,9 @@
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once
#include "api/Print.h"
#include "api/Stream.h"
#include "api/String.h"

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once

View File

@ -0,0 +1,33 @@
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
class Print {
public:
virtual ~Print() {}
virtual size_t write(uint8_t) = 0;
virtual size_t write(const uint8_t *buffer, size_t size) = 0;
size_t write(const char *str) {
if (!str)
return 0;
return write(reinterpret_cast<const uint8_t *>(str), strlen(str));
}
size_t write(const char *buffer, size_t size) {
return write(reinterpret_cast<const uint8_t *>(buffer), size);
}
};
class Printable {
public:
virtual ~Printable() {}
virtual size_t printTo(Print &p) const = 0;
};

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once

View File

@ -1,5 +1,5 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once
@ -9,12 +9,15 @@
// Reproduces Arduino's String class
class String {
public:
String() {}
explicit String(const char* s) : _str(s) {}
String() : _maxCapacity(1024) {}
explicit String(const char* s) : _str(s), _maxCapacity(1024) {}
String& operator+=(const char* rhs) {
_str += rhs;
return *this;
void limitCapacityTo(size_t maxCapacity) {
_maxCapacity = maxCapacity;
}
unsigned char concat(const char* s) {
return concat(s, strlen(s));
}
size_t length() const {
@ -34,8 +37,18 @@ class String {
return lhs;
}
protected:
// This function is protected in most Arduino cores
unsigned char concat(const char* s, size_t n) {
if (_str.size() + n > _maxCapacity)
return 0;
_str.append(s, n);
return 1;
}
private:
std::string _str;
size_t _maxCapacity;
};
class StringSumHelper;

View File

@ -1,10 +1,12 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2020
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#include <stdint.h> // uint8_t
#include <string.h> // strcmp, strlen...
#define PROGMEM
class __FlashStringHelper;
inline const void* convertPtrToFlash(const void* s) {
@ -15,9 +17,26 @@ inline const void* convertFlashToPtr(const void* s) {
return reinterpret_cast<const char*>(s) - 42;
}
#define F(X) reinterpret_cast<const __FlashStringHelper*>(convertPtrToFlash(X))
#define FC(X) reinterpret_cast<const char*>(convertPtrToFlash(X))
#define PSTR(X) reinterpret_cast<const char*>(convertPtrToFlash(X))
#define F(X) reinterpret_cast<const __FlashStringHelper*>(PSTR(X))
inline uint8_t pgm_read_byte(const void* p) {
return *reinterpret_cast<const uint8_t*>(convertFlashToPtr(p));
}
inline void* pgm_read_ptr(const void* p) {
return *reinterpret_cast<void* const*>(convertFlashToPtr(p));
}
inline float pgm_read_float(const void* p) {
return *reinterpret_cast<const float*>(convertFlashToPtr(p));
}
inline uint32_t pgm_read_dword(const void* p) {
return *reinterpret_cast<const uint32_t*>(convertFlashToPtr(p));
}
#define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \
static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \
static type const* name = reinterpret_cast<type const*>( \
convertPtrToFlash(ARDUINOJSON_CONCAT2(name, _progmem)));

View File

@ -1,5 +1,5 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2020
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
add_executable(IntegrationTests
@ -17,3 +17,8 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
endif()
add_test(IntegrationTests IntegrationTests)
set_tests_properties(IntegrationTests
PROPERTIES
LABELS "Catch"
)

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
# ArduinoJson - arduinojson.org
# Copyright Benoit Blanchon 2014-2020
# ArduinoJson - https://arduinojson.org
# Copyright Benoit Blanchon 2014-2021
# MIT License
add_executable(JsonArrayTests
add.cpp
clear.cpp
copyArray.cpp
createNested.cpp
equals.cpp
@ -20,3 +21,8 @@ add_executable(JsonArrayTests
)
add_test(JsonArray JsonArrayTests)
set_tests_properties(JsonArray
PROPERTIES
LABELS "Catch"
)

View File

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

View File

@ -0,0 +1,25 @@
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
TEST_CASE("JsonArray::clear()") {
SECTION("No-op on null JsonArray") {
JsonArray array;
array.clear();
REQUIRE(array.isNull() == true);
REQUIRE(array.size() == 0);
}
SECTION("Removes all elements") {
StaticJsonDocument<64> doc;
JsonArray array = doc.to<JsonArray>();
array.add(1);
array.add(2);
array.clear();
REQUIRE(array.size() == 0);
REQUIRE(array.isNull() == false);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

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