forked from bblanchon/ArduinoJson
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
5bc6a3077a | |||
31a729d35c | |||
48dec78781 | |||
8cc190b7bf | |||
b1a58f3c0c | |||
fe6de3a82b | |||
e27439f3cd | |||
7e093ffc25 | |||
8e3286aac8 | |||
c07744dc0d | |||
733bc4ee82 | |||
9aa77994b4 | |||
f051f8328d | |||
411424b74e | |||
5e5c287978 | |||
377cf63075 | |||
3252013509 | |||
deab127a2f | |||
96281de682 | |||
f0e84e4933 | |||
91397f9f06 | |||
7f75985e47 | |||
05b68fc7cc | |||
b06cee8f4d | |||
e03d8ae885 | |||
cb1dcfa5e4 | |||
67dd3120e6 | |||
9f3cf04415 | |||
01e49b33b7 |
69
.github/workflows/ci.yml
vendored
69
.github/workflows/ci.yml
vendored
@ -93,44 +93,40 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- clang: "3.9"
|
|
||||||
runner: ubuntu-20.04
|
|
||||||
archive: bionic
|
|
||||||
- clang: "4.0"
|
|
||||||
runner: ubuntu-20.04
|
|
||||||
archive: bionic
|
|
||||||
- clang: "5.0"
|
|
||||||
runner: ubuntu-20.04
|
|
||||||
archive: bionic
|
|
||||||
- clang: "6.0"
|
|
||||||
runner: ubuntu-20.04
|
|
||||||
archive: bionic
|
|
||||||
- clang: "7"
|
- clang: "7"
|
||||||
runner: ubuntu-20.04
|
runner: ubuntu-22.04
|
||||||
|
archive: focal
|
||||||
- clang: "8"
|
- clang: "8"
|
||||||
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
|
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
|
||||||
runner: ubuntu-20.04
|
runner: ubuntu-22.04
|
||||||
|
archive: focal
|
||||||
- clang: "9"
|
- clang: "9"
|
||||||
cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
|
cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
|
||||||
runner: ubuntu-20.04
|
runner: ubuntu-22.04
|
||||||
|
archive: focal
|
||||||
- clang: "10"
|
- clang: "10"
|
||||||
cxxflags: -fsanitize=address -fno-sanitize-recover=all
|
cxxflags: -fsanitize=address -fno-sanitize-recover=all
|
||||||
runner: ubuntu-20.04
|
runner: ubuntu-22.04
|
||||||
|
archive: focal
|
||||||
- clang: "11"
|
- clang: "11"
|
||||||
runner: ubuntu-22.04
|
runner: ubuntu-22.04
|
||||||
- clang: "12"
|
- clang: "12"
|
||||||
runner: ubuntu-22.04
|
runner: ubuntu-22.04
|
||||||
- clang: "13"
|
- clang: "13"
|
||||||
runner: ubuntu-22.04
|
runner: ubuntu-22.04
|
||||||
- clang: "14"
|
- clang: 14
|
||||||
runner: ubuntu-22.04
|
- clang: 15
|
||||||
- clang: "15"
|
- clang: 16
|
||||||
runner: ubuntu-22.04
|
- clang: 17
|
||||||
runs-on: ${{ matrix.runner }}
|
- clang: 18
|
||||||
|
- clang: 19
|
||||||
|
runs-on: ${{ matrix.runner || 'ubuntu-latest' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Add archive repositories
|
- name: Add archive repositories
|
||||||
if: matrix.archive
|
if: matrix.archive
|
||||||
run: |
|
run: |
|
||||||
|
sudo gpg --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
|
||||||
|
sudo gpg --export 3B4FE6ACC0B21F32 | sudo tee /etc/apt/trusted.gpg.d/ubuntu-keyring.gpg > /dev/null
|
||||||
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ ${{ matrix.archive }} main'
|
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ ${{ matrix.archive }} main'
|
||||||
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ ${{ matrix.archive }} universe'
|
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ ${{ matrix.archive }} universe'
|
||||||
- name: Install Clang ${{ matrix.clang }}
|
- name: Install Clang ${{ matrix.clang }}
|
||||||
@ -138,7 +134,6 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y clang-${{ matrix.clang }}
|
sudo apt-get install -y clang-${{ matrix.clang }}
|
||||||
- name: Install libc++ ${{ matrix.clang }}
|
- name: Install libc++ ${{ matrix.clang }}
|
||||||
if: matrix.clang >= 11
|
|
||||||
run: sudo apt-get install -y libc++-${{ matrix.clang }}-dev libc++abi-${{ matrix.clang }}-dev
|
run: sudo apt-get install -y libc++-${{ matrix.clang }}-dev libc++abi-${{ matrix.clang }}-dev
|
||||||
- name: Install libunwind ${{ matrix.clang }}
|
- name: Install libunwind ${{ matrix.clang }}
|
||||||
if: matrix.clang == 12 # dependency is missing in Ubuntu 22.04
|
if: matrix.clang == 12 # dependency is missing in Ubuntu 22.04
|
||||||
@ -163,7 +158,7 @@ jobs:
|
|||||||
conf_test:
|
conf_test:
|
||||||
name: Test configuration on Linux
|
name: Test configuration on Linux
|
||||||
needs: [gcc, clang]
|
needs: [gcc, clang]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
@ -184,19 +179,19 @@ jobs:
|
|||||||
|
|
||||||
conf_test_windows:
|
conf_test_windows:
|
||||||
name: Test configuration on Windows
|
name: Test configuration on Windows
|
||||||
runs-on: windows-2019
|
runs-on: windows-2022
|
||||||
needs: [gcc, clang]
|
needs: [gcc, clang]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: 32-bit
|
- name: 32-bit
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
|
||||||
cl /Isrc extras/conf_test/x86.cpp
|
cl /Isrc extras/conf_test/x86.cpp
|
||||||
shell: cmd
|
shell: cmd
|
||||||
- name: 64-bit
|
- name: 64-bit
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
cl /Isrc extras/conf_test/x64.cpp
|
cl /Isrc extras/conf_test/x64.cpp
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
@ -257,7 +252,7 @@ jobs:
|
|||||||
board: arduino:avr:uno
|
board: arduino:avr:uno
|
||||||
- core: arduino:samd
|
- core: arduino:samd
|
||||||
board: arduino:samd:mkr1000
|
board: arduino:samd:mkr1000
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -412,7 +407,7 @@ jobs:
|
|||||||
arm:
|
arm:
|
||||||
name: GCC for ARM processor
|
name: GCC for ARM processor
|
||||||
needs: gcc
|
needs: gcc
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
@ -431,7 +426,7 @@ jobs:
|
|||||||
coverage:
|
coverage:
|
||||||
needs: gcc
|
needs: gcc
|
||||||
name: Coverage
|
name: Coverage
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Install
|
- name: Install
|
||||||
run: sudo apt-get install -y lcov ninja-build
|
run: sudo apt-get install -y lcov ninja-build
|
||||||
@ -463,7 +458,7 @@ jobs:
|
|||||||
valgrind:
|
valgrind:
|
||||||
needs: gcc
|
needs: gcc
|
||||||
name: Valgrind
|
name: Valgrind
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
@ -485,24 +480,24 @@ jobs:
|
|||||||
clang-tidy:
|
clang-tidy:
|
||||||
needs: clang
|
needs: clang
|
||||||
name: Clang-Tidy
|
name: Clang-Tidy
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install
|
- name: Install
|
||||||
run: sudo apt-get install -y clang-tidy cmake ninja-build
|
run: sudo apt-get install -y clang-tidy libc++-dev libc++abi-dev
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy-10;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
|
run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
|
||||||
env:
|
env:
|
||||||
CC: clang-10
|
CC: clang
|
||||||
CXX: clang++-10
|
CXX: clang++
|
||||||
- name: Check
|
- name: Check
|
||||||
run: cmake --build . -- -k 0
|
run: cmake --build . -- -k 0
|
||||||
|
|
||||||
amalgamate:
|
amalgamate:
|
||||||
needs: gcc
|
needs: gcc
|
||||||
name: Amalgamate ArduinoJson.h
|
name: Amalgamate ArduinoJson.h
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -578,7 +573,7 @@ jobs:
|
|||||||
|
|
||||||
codeql:
|
codeql:
|
||||||
name: CodeQL
|
name: CodeQL
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
needs: gcc
|
needs: gcc
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -8,7 +8,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
name: Create release
|
name: Create release
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Set variables
|
- name: Set variables
|
||||||
id: init
|
id: init
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include "src/ArduinoJson.h"
|
#include "src/ArduinoJson.h"
|
||||||
|
59
CHANGELOG.md
59
CHANGELOG.md
@ -1,6 +1,65 @@
|
|||||||
ArduinoJson: change log
|
ArduinoJson: change log
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
HEAD
|
||||||
|
----
|
||||||
|
|
||||||
|
* Optimize storage of static strings
|
||||||
|
|
||||||
|
> ### BREAKING CHANGES
|
||||||
|
>
|
||||||
|
> Static string cannot contain NUL characters anymore (they could since 7.3.0).
|
||||||
|
> This is an extremely rare case, so you probably won't be affected.
|
||||||
|
>
|
||||||
|
> For example, the following code produces different output in 7.3 and 7.4:
|
||||||
|
>
|
||||||
|
> ```cpp
|
||||||
|
> JsonDocument doc;
|
||||||
|
> doc["a\0b"] = "c\0d";
|
||||||
|
> serializeJson(doc, Serial);
|
||||||
|
> // With Arduino 7.3 -> {"a\u0000b":"c\u0000d"}
|
||||||
|
> // With Arduino 7.4 -> {"a":"c"}
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> `JsonString` contructor now only accepts two arguments, not three.
|
||||||
|
> If your code uses `JsonString` to store a string as a pointer, you must remove the size argument.
|
||||||
|
>
|
||||||
|
> For example, if you have something like this:
|
||||||
|
>
|
||||||
|
> ```cpp
|
||||||
|
> doc["key"] = JsonString(str.c_str(), str.size(), true);
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> You must replace with either:
|
||||||
|
>
|
||||||
|
> ```cpp
|
||||||
|
> doc["key"] = JsonString(str.c_str(), true); // store as pointer, cannot contain NUL characters
|
||||||
|
> doc["key"] = JsonString(str.c_str(), str.size()); // store by copy, NUL characters allowed
|
||||||
|
> doc["key"] = str; // same as previous line for supported string classes (`String`, `std::string`, etc.)
|
||||||
|
> ```
|
||||||
|
|
||||||
|
v7.4.2 (2025-06-20)
|
||||||
|
------
|
||||||
|
|
||||||
|
* Fix truncated strings on Arduino Due (issue #2181)
|
||||||
|
|
||||||
|
v7.4.1 (2025-04-11)
|
||||||
|
------
|
||||||
|
|
||||||
|
* Fix crash with tiny Flash strings (issue #2170)
|
||||||
|
|
||||||
|
v7.4.0 (2025-04-09)
|
||||||
|
------
|
||||||
|
|
||||||
|
* Optimize storage of tiny strings (up to 3 characters)
|
||||||
|
* Fix support for `const char[]` (issue #2166)
|
||||||
|
|
||||||
|
v7.3.1 (2025-02-27)
|
||||||
|
------
|
||||||
|
|
||||||
|
* Fix conversion from static string to number
|
||||||
|
* Slightly reduce code size
|
||||||
|
|
||||||
v7.3.0 (2024-12-29)
|
v7.3.0 (2024-12-29)
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
@ -10,7 +10,7 @@ if(ESP_PLATFORM)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(ArduinoJson VERSION 7.3.0)
|
project(ArduinoJson VERSION 7.4.2)
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
Copyright © 2014-2024, Benoit BLANCHON
|
Copyright © 2014-2025, 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:
|
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:
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
|
|||||||
* Continuously tested on
|
* Continuously tested on
|
||||||
* [Visual Studio 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/7.x)
|
* [Visual Studio 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/7.x)
|
||||||
* [GCC 4.8, 5, 6, 7, 8, 9, 10, 11, 12](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
* [GCC 4.8, 5, 6, 7, 8, 9, 10, 11, 12](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
||||||
* [Clang 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10, 11, 12, 13, 14, 15](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
* [Clang 7 to 19](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)
|
* [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/)
|
* Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/)
|
||||||
* Well documented
|
* Well documented
|
||||||
@ -139,11 +139,6 @@ See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/serializati
|
|||||||
|
|
||||||
ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it!
|
ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it!
|
||||||
|
|
||||||
<p>
|
|
||||||
<a href="https://www.programmingelectronics.com/" rel="sponsored">
|
|
||||||
<img src="https://arduinojson.org/images/2021/10/programmingeleactronicsacademy.png" alt="Programming Electronics Academy" width="200">
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
<p>
|
<p>
|
||||||
<a href="https://github.com/1technophile" rel="sponsored">
|
<a href="https://github.com/1technophile" rel="sponsored">
|
||||||
<img alt="1technophile" src="https://avatars.githubusercontent.com/u/12672732?s=40&v=4">
|
<img alt="1technophile" src="https://avatars.githubusercontent.com/u/12672732?s=40&v=4">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 7.3.0.{build}
|
version: 7.4.2.{build}
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to store your project configuration in a file.
|
// This example shows how to store your project configuration in a file.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to use DeserializationOption::Filter
|
// This example shows how to use DeserializationOption::Filter
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to generate a JSON document with ArduinoJson.
|
// This example shows how to generate a JSON document with ArduinoJson.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to parse a JSON document in an HTTP response.
|
// This example shows how to parse a JSON document in an HTTP response.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to deserialize a JSON document with ArduinoJson.
|
// This example shows how to deserialize a JSON document with ArduinoJson.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to implement an HTTP server that sends a JSON document
|
// This example shows how to implement an HTTP server that sends a JSON document
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to send a JSON document to a UDP socket.
|
// This example shows how to send a JSON document to a UDP socket.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to deserialize a MessagePack document with
|
// This example shows how to deserialize a MessagePack document with
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows the different ways you can use Flash strings with
|
// This example shows the different ways you can use Flash strings with
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows the different ways you can use String with ArduinoJson.
|
// This example shows the different ways you can use String with ArduinoJson.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
idf_component_register(
|
idf_component_register(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -12,7 +12,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 6, "slot size");
|
static_assert(sizeof(ArduinoJson::detail::VariantData) == 6, "slot size");
|
||||||
|
|
||||||
void setup() {}
|
void setup() {}
|
||||||
void loop() {}
|
void loop() {}
|
||||||
|
@ -10,7 +10,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 8, "slot size");
|
static_assert(sizeof(ArduinoJson::detail::VariantData) == 8, "slot size");
|
||||||
|
|
||||||
void setup() {}
|
void setup() {}
|
||||||
void loop() {}
|
void loop() {}
|
||||||
|
@ -10,7 +10,6 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 16,
|
static_assert(sizeof(ArduinoJson::detail::VariantData) == 16, "slot size");
|
||||||
"slot size");
|
|
||||||
|
|
||||||
int main() {}
|
int main() {}
|
||||||
|
@ -10,6 +10,6 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
|
|||||||
|
|
||||||
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
|
||||||
|
|
||||||
static_assert(ArduinoJson::detail::ResourceManager::slotSize == 8, "slot size");
|
static_assert(sizeof(ArduinoJson::detail::VariantData) == 8, "slot size");
|
||||||
|
|
||||||
int main() {}
|
int main() {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
// This file is NOT use by Google's OSS fuzz
|
// This file is NOT use by Google's OSS fuzz
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to generate a JSON document with ArduinoJson.
|
// This example shows how to generate a JSON document with ArduinoJson.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to deserialize a JSON document with ArduinoJson.
|
// This example shows how to deserialize a JSON document with ArduinoJson.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
//
|
//
|
||||||
// This example shows how to generate a JSON document with ArduinoJson.
|
// This example shows how to generate a JSON document with ArduinoJson.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
if(MSVC_VERSION LESS 1910)
|
if(MSVC_VERSION LESS 1910)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
// we expect ArduinoJson.h to include <string_view>
|
// we expect ArduinoJson.h to include <string_view>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
if(MSVC_VERSION LESS 1910)
|
if(MSVC_VERSION LESS 1910)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -46,7 +46,7 @@ TEST_CASE("BasicJsonDocument") {
|
|||||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||||
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
|
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
|
||||||
doc.clear();
|
doc.clear();
|
||||||
REQUIRE(allocatorLog == "ARAARDDD");
|
REQUIRE(allocatorLog == "AARARDDD");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("copy") {
|
SECTION("copy") {
|
||||||
@ -54,7 +54,7 @@ TEST_CASE("BasicJsonDocument") {
|
|||||||
doc["hello"] = "world";
|
doc["hello"] = "world";
|
||||||
auto copy = doc;
|
auto copy = doc;
|
||||||
REQUIRE(copy.as<std::string>() == "{\"hello\":\"world\"}");
|
REQUIRE(copy.as<std::string>() == "{\"hello\":\"world\"}");
|
||||||
REQUIRE(allocatorLog == "AA");
|
REQUIRE(allocatorLog == "AAAA");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("capacity") {
|
SECTION("capacity") {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
macro(add_failing_build source_file)
|
macro(add_failing_build source_file)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#define ARDUINOJSON_USE_LONG_LONG 0
|
#define ARDUINOJSON_USE_LONG_LONG 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#define ARDUINOJSON_USE_LONG_LONG 0
|
#define ARDUINOJSON_USE_LONG_LONG 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -269,10 +269,16 @@ inline size_t sizeofPoolList(size_t n = ARDUINOJSON_INITIAL_POOL_COUNT) {
|
|||||||
return sizeof(MemoryPool<VariantData>) * n;
|
return sizeof(MemoryPool<VariantData>) * n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T = ArduinoJson::detail::VariantData>
|
||||||
inline size_t sizeofPool(
|
inline size_t sizeofPool(
|
||||||
ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
|
ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
|
||||||
|
return ArduinoJson::detail::MemoryPool<T>::slotsToBytes(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t sizeofStaticStringPool(
|
||||||
|
ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
|
||||||
using namespace ArduinoJson::detail;
|
using namespace ArduinoJson::detail;
|
||||||
return MemoryPool<VariantData>::slotsToBytes(n);
|
return MemoryPool<const char*>::slotsToBytes(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t sizeofStringBuffer(size_t iteration = 1) {
|
inline size_t sizeofStringBuffer(size_t iteration = 1) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
add_executable(IntegrationTests
|
add_executable(IntegrationTests
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
add_executable(JsonArrayTests
|
add_executable(JsonArrayTests
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -8,7 +8,7 @@
|
|||||||
#include "Allocators.hpp"
|
#include "Allocators.hpp"
|
||||||
#include "Literals.hpp"
|
#include "Literals.hpp"
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using namespace ArduinoJson::detail;
|
||||||
|
|
||||||
TEST_CASE("JsonArray::add(T)") {
|
TEST_CASE("JsonArray::add(T)") {
|
||||||
SpyingAllocator spy;
|
SpyingAllocator spy;
|
||||||
@ -33,7 +33,8 @@ TEST_CASE("JsonArray::add(T)") {
|
|||||||
REQUIRE(array[0].is<double>());
|
REQUIRE(array[0].is<double>());
|
||||||
REQUIRE_FALSE(array[0].is<bool>());
|
REQUIRE_FALSE(array[0].is<bool>());
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool<VariantData>()),
|
||||||
|
Allocate(sizeofPool<EightByteValue>()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +57,7 @@ TEST_CASE("JsonArray::add(T)") {
|
|||||||
REQUIRE(array[0].is<int>() == false);
|
REQUIRE(array[0].is<int>() == false);
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
add_executable(JsonArrayConstTests
|
add_executable(JsonArrayConstTests
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
add_executable(JsonDeserializerTests
|
add_executable(JsonDeserializerTests
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "Allocators.hpp"
|
#include "Allocators.hpp"
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using namespace ArduinoJson::detail;
|
||||||
|
|
||||||
TEST_CASE("deserialize JSON array") {
|
TEST_CASE("deserialize JSON array") {
|
||||||
SpyingAllocator spy;
|
SpyingAllocator spy;
|
||||||
@ -92,8 +92,12 @@ TEST_CASE("deserialize JSON array") {
|
|||||||
REQUIRE(arr[0].as<double>() == Approx(4.2123456));
|
REQUIRE(arr[0].as<double>() == Approx(4.2123456));
|
||||||
REQUIRE(arr[1] == -7E89);
|
REQUIRE(arr[1] == -7E89);
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool<VariantData>()),
|
||||||
Reallocate(sizeofPool(), sizeofPool(4)),
|
Allocate(sizeofPool<EightByteValue>()),
|
||||||
|
Reallocate(sizeofPool<VariantData>(),
|
||||||
|
sizeofPool<VariantData>(2)),
|
||||||
|
Reallocate(sizeofPool<EightByteValue>(),
|
||||||
|
sizeofPool<EightByteValue>(2)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -104,6 +104,8 @@ TEST_CASE("deserializeJson(MemberProxy)") {
|
|||||||
|
|
||||||
REQUIRE(err == DeserializationError::Ok);
|
REQUIRE(err == DeserializationError::Ok);
|
||||||
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\",\"value\":[42]}");
|
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\",\"value\":[42]}");
|
||||||
REQUIRE(spy.log() == AllocatorLog{});
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#define ARDUINOJSON_DECODE_UNICODE 1
|
#define ARDUINOJSON_DECODE_UNICODE 1
|
||||||
@ -121,7 +121,7 @@ TEST_CASE("deserializeJson() returns NoMemory if string length overflows") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("deserializeJson() returns NoMemory if extension allocation fails") {
|
TEST_CASE("deserializeJson() returns NoMemory if 8-bit slot allocation fails") {
|
||||||
JsonDocument doc(FailingAllocator::instance());
|
JsonDocument doc(FailingAllocator::instance());
|
||||||
|
|
||||||
SECTION("uint32_t should pass") {
|
SECTION("uint32_t should pass") {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#define ARDUINOJSON_ENABLE_COMMENTS 1
|
#define ARDUINOJSON_ENABLE_COMMENTS 1
|
||||||
@ -825,7 +825,9 @@ TEST_CASE("shrink filter") {
|
|||||||
|
|
||||||
deserializeJson(doc, "{}", DeserializationOption::Filter(filter));
|
deserializeJson(doc, "{}", DeserializationOption::Filter(filter));
|
||||||
|
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() ==
|
||||||
|
AllocatorLog{
|
||||||
Reallocate(sizeofPool(), sizeofObject(1)),
|
Reallocate(sizeofPool(), sizeofObject(1)),
|
||||||
|
Reallocate(sizeofStaticStringPool(), sizeofStaticStringPool(1)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -26,8 +26,8 @@ TEST_CASE("deserializeJson(char*)") {
|
|||||||
REQUIRE(spy.log() ==
|
REQUIRE(spy.log() ==
|
||||||
AllocatorLog{
|
AllocatorLog{
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofStringBuffer(), sizeofString("hello")),
|
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Reallocate(sizeofStringBuffer(), sizeofString("hello")),
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofStringBuffer(), sizeofString("world")),
|
Reallocate(sizeofStringBuffer(), sizeofString("world")),
|
||||||
Reallocate(sizeofPool(), sizeofObject(1)),
|
Reallocate(sizeofPool(), sizeofObject(1)),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#define ARDUINOJSON_USE_LONG_LONG 0
|
#define ARDUINOJSON_USE_LONG_LONG 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -292,22 +292,23 @@ TEST_CASE("deserialize JSON object") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Repeated key") {
|
SECTION("Repeated key") {
|
||||||
DeserializationError err = deserializeJson(doc, "{a:{b:{c:1}},a:2}");
|
DeserializationError err =
|
||||||
|
deserializeJson(doc, "{alfa:{bravo:{charlie:1}},alfa:2}");
|
||||||
|
|
||||||
REQUIRE(err == DeserializationError::Ok);
|
REQUIRE(err == DeserializationError::Ok);
|
||||||
REQUIRE(doc.as<std::string>() == "{\"a\":2}");
|
REQUIRE(doc.as<std::string>() == "{\"alfa\":2}");
|
||||||
REQUIRE(spy.log() ==
|
REQUIRE(spy.log() ==
|
||||||
AllocatorLog{
|
AllocatorLog{
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofStringBuffer(), sizeofString("a")),
|
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Reallocate(sizeofStringBuffer(), sizeofString("alfa")),
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofStringBuffer(), sizeofString("b")),
|
Reallocate(sizeofStringBuffer(), sizeofString("bravo")),
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofStringBuffer(), sizeofString("c")),
|
Reallocate(sizeofStringBuffer(), sizeofString("charlie")),
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Deallocate(sizeofString("b")),
|
Deallocate(sizeofString("bravo")),
|
||||||
Deallocate(sizeofString("c")),
|
Deallocate(sizeofString("charlie")),
|
||||||
Deallocate(sizeofStringBuffer()),
|
Deallocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofPool(), sizeofObject(2) + sizeofObject(1)),
|
Reallocate(sizeofPool(), sizeofObject(2) + sizeofObject(1)),
|
||||||
});
|
});
|
||||||
@ -378,7 +379,7 @@ TEST_CASE("deserialize JSON object under memory constraints") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("pool allocation fails") {
|
SECTION("pool allocation fails") {
|
||||||
timebomb.setCountdown(2);
|
timebomb.setCountdown(1);
|
||||||
char input[] = "{\"a\":1}";
|
char input[] = "{\"a\":1}";
|
||||||
|
|
||||||
DeserializationError err = deserializeJson(doc, input);
|
DeserializationError err = deserializeJson(doc, input);
|
||||||
@ -389,11 +390,11 @@ TEST_CASE("deserialize JSON object under memory constraints") {
|
|||||||
|
|
||||||
SECTION("string allocation fails") {
|
SECTION("string allocation fails") {
|
||||||
timebomb.setCountdown(3);
|
timebomb.setCountdown(3);
|
||||||
char input[] = "{\"a\":\"b\"}";
|
char input[] = "{\"alfa\":\"bravo\"}";
|
||||||
|
|
||||||
DeserializationError err = deserializeJson(doc, input);
|
DeserializationError err = deserializeJson(doc, input);
|
||||||
|
|
||||||
REQUIRE(err == DeserializationError::NoMemory);
|
REQUIRE(err == DeserializationError::NoMemory);
|
||||||
REQUIRE(doc.as<std::string>() == "{\"a\":null}");
|
REQUIRE(doc.as<std::string>() == "{\"alfa\":null}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#define ARDUINOJSON_DECODE_UNICODE 1
|
#define ARDUINOJSON_DECODE_UNICODE 1
|
||||||
@ -133,8 +133,8 @@ TEST_CASE("Allocation of the key fails") {
|
|||||||
REQUIRE(spy.log() ==
|
REQUIRE(spy.log() ==
|
||||||
AllocatorLog{
|
AllocatorLog{
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofStringBuffer(), sizeofString("hello")),
|
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Reallocate(sizeofStringBuffer(), sizeofString("hello")),
|
||||||
AllocateFail(sizeofStringBuffer()),
|
AllocateFail(sizeofStringBuffer()),
|
||||||
ReallocateFail(sizeofPool(), sizeofObject(1)),
|
ReallocateFail(sizeofPool(), sizeofObject(1)),
|
||||||
});
|
});
|
||||||
@ -155,8 +155,8 @@ TEST_CASE("Allocation of the key fails") {
|
|||||||
REQUIRE(spy.log() ==
|
REQUIRE(spy.log() ==
|
||||||
AllocatorLog{
|
AllocatorLog{
|
||||||
Allocate(sizeofStringBuffer()),
|
Allocate(sizeofStringBuffer()),
|
||||||
Reallocate(sizeofStringBuffer(), sizeofString("hello")),
|
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Reallocate(sizeofStringBuffer(), sizeofString("hello")),
|
||||||
AllocateFail(sizeofStringBuffer()),
|
AllocateFail(sizeofStringBuffer()),
|
||||||
ReallocateFail(sizeofPool(), sizeofObject(1)),
|
ReallocateFail(sizeofPool(), sizeofObject(1)),
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# ArduinoJson - https://arduinojson.org
|
# ArduinoJson - https://arduinojson.org
|
||||||
# Copyright © 2014-2024, Benoit BLANCHON
|
# Copyright © 2014-2025, Benoit BLANCHON
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
add_executable(JsonDocumentTests
|
add_executable(JsonDocumentTests
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -31,6 +31,7 @@ TEST_CASE("ElementProxy::add()") {
|
|||||||
REQUIRE(doc.as<std::string>() == "[[\"world\"]]");
|
REQUIRE(doc.as<std::string>() == "[[\"world\"]]");
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
// ArduinoJson - https://arduinojson.org
|
||||||
// Copyright © 2014-2024, Benoit BLANCHON
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
|
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
|
||||||
@ -25,6 +25,7 @@ TEST_CASE("MemberProxy::add()") {
|
|||||||
REQUIRE(doc.as<std::string>() == "{\"hello\":[42]}");
|
REQUIRE(doc.as<std::string>() == "{\"hello\":[42]}");
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ TEST_CASE("MemberProxy::add()") {
|
|||||||
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +46,7 @@ TEST_CASE("MemberProxy::add()") {
|
|||||||
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
Allocate(sizeofString("world")),
|
Allocate(sizeofString("world")),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -55,8 +58,8 @@ TEST_CASE("MemberProxy::add()") {
|
|||||||
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
Allocate(sizeofString("world")),
|
Allocate(sizeofString("world")),
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +74,7 @@ TEST_CASE("MemberProxy::add()") {
|
|||||||
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
REQUIRE(doc.as<std::string>() == "{\"hello\":[\"world\"]}");
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
Allocate(sizeofString("world")),
|
Allocate(sizeofString("world")),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -399,7 +403,7 @@ TEST_CASE("MemberProxy under memory constraints") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("value slot allocation fails") {
|
SECTION("value slot allocation fails") {
|
||||||
timebomb.setCountdown(1);
|
timebomb.setCountdown(2);
|
||||||
|
|
||||||
// fill the pool entirely, but leave one slot for the key
|
// fill the pool entirely, but leave one slot for the key
|
||||||
doc["foo"][ARDUINOJSON_POOL_CAPACITY - 4] = 1;
|
doc["foo"][ARDUINOJSON_POOL_CAPACITY - 4] = 1;
|
||||||
@ -412,6 +416,7 @@ TEST_CASE("MemberProxy under memory constraints") {
|
|||||||
REQUIRE(doc.overflowed() == true);
|
REQUIRE(doc.overflowed() == true);
|
||||||
REQUIRE(spy.log() == AllocatorLog{
|
REQUIRE(spy.log() == AllocatorLog{
|
||||||
Allocate(sizeofPool()),
|
Allocate(sizeofPool()),
|
||||||
|
Allocate(sizeofStaticStringPool()),
|
||||||
AllocateFail(sizeofPool()),
|
AllocateFail(sizeofPool()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user