Compare commits

...

29 Commits
v7.3.0 ... 7.5

Author SHA1 Message Date
5bc6a3077a Move VariantImpl definition to VariantImpl.hpp 2025-06-26 20:48:13 +02:00
31a729d35c Extract VariantImpl 2025-06-26 20:48:13 +02:00
48dec78781 Extract ArrayImpl, CollectionImpl, and ObjectImpl 2025-06-26 20:48:13 +02:00
8cc190b7bf JsonObject: replace ObjectData* member with VariantData* 2025-06-26 20:48:13 +02:00
b1a58f3c0c JsonArray: replace ArrayData* member with VariantData* 2025-06-26 20:48:13 +02:00
fe6de3a82b JsonObjectConst: replace ObjectData* member with VariantData* 2025-06-26 20:48:13 +02:00
e27439f3cd JsonArrayConst: replace ArrayData* member with VariantData* 2025-06-26 20:48:13 +02:00
7e093ffc25 Add a pool dedicated to 8-byte values (double/int64_t/uint64_t)
This new pool replaced the "extension" slot where a secondary variant slot was used to store 8-byte values.
2025-06-26 20:48:13 +02:00
8e3286aac8 Store static strings in a dedicated pool
Because a slot id is smaller than a pointer, this change will ultimately allow reducing the slot size.
2025-06-26 20:48:13 +02:00
c07744dc0d CI: upgrade Windows runner 2025-06-26 20:47:57 +02:00
733bc4ee82 Set version to 7.4.2 2025-06-20 09:37:14 +02:00
9aa77994b4 Remove sponsor Programming Electronics Academy 2025-06-20 08:43:48 +02:00
f051f8328d Undef true and false macros
Replacing `true` with `1` changes `JsonString("ABC", true)` into `JsonString("ABC", 1)`, so all static strings had a length of 1.

This is a workaround for arduino/ArduinoCore-sam#50
Fixes #2181
2025-06-19 13:59:15 +02:00
411424b74e CI: upgrade clang-tidy 2025-05-20 20:55:01 +02:00
5e5c287978 CI: upgrade Clang versions 2025-05-20 18:24:46 +02:00
377cf63075 CI: upgrade runner to ubuntu-22.04 2025-05-20 14:48:42 +02:00
3252013509 Set version to 7.4.1 2025-04-11 15:43:42 +02:00
deab127a2f Fix crash with tiny Flash strings (issue #2170) 2025-04-11 10:23:43 +02:00
96281de682 Set version to 7.4.0 2025-04-09 14:49:13 +02:00
f0e84e4933 Fix support for const char[]
Fixes #2166
2025-04-09 08:55:09 +02:00
91397f9f06 Optimize storage of tiny strings (up to 3 characters) 2025-04-09 08:55:08 +02:00
7f75985e47 Change StringBuffer::save() to take a VariantData* 2025-02-28 10:05:50 +01:00
05b68fc7cc Change StringBuilder::save() to take a VariantData* 2025-02-28 09:59:46 +01:00
b06cee8f4d Remove the overload of setString() for StringNode 2025-02-28 09:23:56 +01:00
e03d8ae885 Set version to 7.3.1 2025-02-27 19:35:14 +01:00
cb1dcfa5e4 Reduce code size 2025-02-27 11:13:50 +01:00
67dd3120e6 Fix conversion from static string to number 2025-02-27 11:01:51 +01:00
9f3cf04415 Remove useless null check 2025-02-24 16:40:42 +01:00
01e49b33b7 Update copyright year 2025-02-24 15:18:26 +01:00
376 changed files with 2225 additions and 1884 deletions

View File

@ -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,10 +134,9 @@ 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
run: sudo apt-get install -y libunwind-${{ matrix.clang }}-dev run: sudo apt-get install -y libunwind-${{ matrix.clang }}-dev
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -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:
@ -587,20 +582,20 @@ jobs:
security-events: write security-events: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v3
with: with:
languages: cpp languages: cpp
- name: Build - name: Build
run: | run: |
cmake -DCMAKE_BUILD_TYPE=Debug . cmake -DCMAKE_BUILD_TYPE=Debug .
cmake --build . cmake --build .
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3 uses: github/codeql-action/analyze@v3
with: with:
category: "/language:cpp" category: "/language:cpp"

View File

@ -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

View 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 "src/ArduinoJson.h" #include "src/ArduinoJson.h"

View File

@ -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)
------ ------

View 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
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)

View File

@ -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:

View File

@ -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">

View File

@ -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

View 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 store your project configuration in a file. // This example shows how to store your project configuration in a file.

View 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

View 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 generate a JSON document with ArduinoJson. // This example shows how to generate a JSON document with ArduinoJson.

View 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 parse a JSON document in an HTTP response. // This example shows how to parse a JSON document in an HTTP response.

View 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 deserialize a JSON document with ArduinoJson. // This example shows how to deserialize a JSON document with ArduinoJson.

View 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 implement an HTTP server that sends a JSON document // This example shows how to implement an HTTP server that sends a JSON document

View 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 send a JSON document to a UDP socket. // This example shows how to send a JSON document to a UDP socket.

View 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 deserialize a MessagePack document with // This example shows how to deserialize a MessagePack document with

View 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 the different ways you can use Flash strings with // This example shows the different ways you can use Flash strings with

View 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 the different ways you can use String with ArduinoJson. // This example shows the different ways you can use String with ArduinoJson.

View 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
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)

View 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
idf_component_register( idf_component_register(

View 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>

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}

View 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
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)

View 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 file is NOT use by Google's OSS fuzz // This file is NOT use by Google's OSS fuzz

View 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 generate a JSON document with ArduinoJson. // This example shows how to generate a JSON document with ArduinoJson.

View 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 deserialize a JSON document with ArduinoJson. // This example shows how to deserialize a JSON document with ArduinoJson.

View 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 generate a JSON document with ArduinoJson. // This example shows how to generate a JSON document with ArduinoJson.

View 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
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)

View 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
if(MSVC_VERSION LESS 1910) if(MSVC_VERSION LESS 1910)

View 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
// we expect ArduinoJson.h to include <string_view> // we expect ArduinoJson.h to include <string_view>

View 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
if(MSVC_VERSION LESS 1910) if(MSVC_VERSION LESS 1910)

View 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>
@ -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") {

View 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
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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
macro(add_failing_build source_file) macro(add_failing_build source_file)

View 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>

View 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>

View 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>

View 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
#define ARDUINOJSON_USE_LONG_LONG 0 #define ARDUINOJSON_USE_LONG_LONG 0

View 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>

View 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
#define ARDUINOJSON_USE_LONG_LONG 0 #define ARDUINOJSON_USE_LONG_LONG 0

View 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
#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) {

View 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
#pragma once #pragma once

View 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
#pragma once #pragma once

View 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
#pragma once #pragma once

View 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
#pragma once #pragma once
@ -13,21 +13,21 @@ class Print {
virtual ~Print() {} virtual ~Print() {}
virtual size_t write(uint8_t) = 0; virtual size_t write(uint8_t) = 0;
virtual size_t write(const uint8_t *buffer, size_t size) = 0; virtual size_t write(const uint8_t* buffer, size_t size) = 0;
size_t write(const char *str) { size_t write(const char* str) {
if (!str) if (!str)
return 0; return 0;
return write(reinterpret_cast<const uint8_t *>(str), strlen(str)); return write(reinterpret_cast<const uint8_t*>(str), strlen(str));
} }
size_t write(const char *buffer, size_t size) { size_t write(const char* buffer, size_t size) {
return write(reinterpret_cast<const uint8_t *>(buffer), size); return write(reinterpret_cast<const uint8_t*>(buffer), size);
} }
}; };
class Printable { class Printable {
public: public:
virtual ~Printable() {} virtual ~Printable() {}
virtual size_t printTo(Print &p) const = 0; virtual size_t printTo(Print& p) const = 0;
}; };

View 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
#pragma once #pragma once
@ -10,5 +10,5 @@ class Stream // : public Print
public: public:
virtual ~Stream() {} virtual ~Stream() {}
virtual int read() = 0; virtual int read() = 0;
virtual size_t readBytes(char *buffer, size_t length) = 0; virtual size_t readBytes(char* buffer, size_t length) = 0;
}; };

View 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
#pragma once #pragma once

View 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
#pragma once #pragma once

View 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
add_executable(IntegrationTests add_executable(IntegrationTests

View 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>

View 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>

View 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>

View 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>

View 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
add_executable(JsonArrayTests add_executable(JsonArrayTests

View 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>
@ -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()),
}); });
} }

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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
add_executable(JsonArrayConstTests add_executable(JsonArrayConstTests

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>

View 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
add_executable(JsonDeserializerTests add_executable(JsonDeserializerTests

View 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>

View 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>
@ -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)),
}); });
} }

View 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>
@ -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()),
});
} }
} }

View 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
#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") {

View 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
#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() ==
Reallocate(sizeofPool(), sizeofObject(1)), AllocatorLog{
}); Reallocate(sizeofPool(), sizeofObject(1)),
Reallocate(sizeofStaticStringPool(), sizeofStaticStringPool(1)),
});
} }

View 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>
@ -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)),

View 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>

View 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>

View 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
#define ARDUINOJSON_USE_LONG_LONG 0 #define ARDUINOJSON_USE_LONG_LONG 0

View 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>
@ -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}");
} }
} }

View 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
#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)),
}); });

View 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
add_executable(JsonDocumentTests add_executable(JsonDocumentTests

View 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>
@ -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()),
}); });
} }

View 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
#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