├── .prettierignore ├── .gitattributes ├── component.mk ├── extras ├── fuzzing │ ├── json_seed_corpus │ │ ├── EmptyArray.json │ │ ├── EmptyObject.json │ │ ├── IntegerOverflow.json │ │ ├── Strings.json │ │ ├── Comments.json │ │ ├── Numbers.json │ │ ├── ExcessiveNesting.json │ │ └── OpenWeatherMap.json │ ├── msgpack_seed_corpus │ │ ├── fixint_positive │ │ ├── nil │ │ ├── false │ │ ├── int16 │ │ ├── int32 │ │ ├── int64 │ │ ├── int8 │ │ ├── map16 │ │ ├── map32 │ │ ├── str16 │ │ ├── str32 │ │ ├── str8 │ │ ├── true │ │ ├── uint8 │ │ ├── array16 │ │ ├── array32 │ │ ├── fixarray │ │ ├── fixmap │ │ ├── fixstr │ │ ├── float32 │ │ ├── float64 │ │ ├── uint16 │ │ ├── uint32 │ │ ├── uint64 │ │ └── fixint_negative │ ├── json_corpus │ │ └── .gitignore │ ├── msgpack_corpus │ │ └── .gitignore │ ├── json_fuzzer.cpp │ ├── msgpack_fuzzer.cpp │ ├── Makefile │ └── reproducer.cpp ├── particle │ ├── project.properties │ └── src │ │ └── smocktest.ino ├── tests │ ├── catch │ │ ├── .clang-format │ │ ├── catch.cpp │ │ └── CMakeLists.txt │ ├── .clang-tidy │ ├── FailingBuilds │ │ ├── assign_char.cpp │ │ ├── deserialize_object.cpp │ │ ├── variant_as_char.cpp │ │ ├── Issue978.cpp │ │ ├── write_long_long.cpp │ │ ├── read_long_long.cpp │ │ └── CMakeLists.txt │ ├── Misc │ │ ├── custom_string.hpp │ │ ├── issue2181.cpp │ │ ├── issue1967.cpp │ │ ├── version.cpp │ │ ├── NoArduinoHeader.cpp │ │ ├── issue2166.cpp │ │ ├── weird_strcmp.hpp │ │ ├── CMakeLists.txt │ │ ├── issue2129.cpp │ │ ├── Utf8.cpp │ │ └── conflicts.cpp │ ├── Helpers │ │ ├── Arduino.h │ │ ├── Literals.hpp │ │ ├── api │ │ │ ├── Stream.h │ │ │ └── Print.h │ │ ├── CustomReader.hpp │ │ └── avr │ │ │ └── pgmspace.h │ ├── MixedConfiguration │ │ ├── decode_unicode_1.cpp │ │ ├── decode_unicode_0.cpp │ │ ├── use_double_1.cpp │ │ ├── issue1707.cpp │ │ ├── use_long_long_1.cpp │ │ ├── enable_nan_0.cpp │ │ ├── enable_nan_1.cpp │ │ ├── CMakeLists.txt │ │ ├── use_long_long_0.cpp │ │ ├── enable_infinity_1.cpp │ │ ├── enable_infinity_0.cpp │ │ ├── enable_alignment_1.cpp │ │ └── enable_alignment_0.cpp │ ├── Cpp20 │ │ ├── smoke_test.cpp │ │ └── CMakeLists.txt │ ├── Deprecated │ │ ├── shallowCopy.cpp │ │ ├── macros.cpp │ │ ├── CMakeLists.txt │ │ ├── StaticJsonDocument.cpp │ │ ├── add.cpp │ │ ├── DynamicJsonDocument.cpp │ │ └── memoryUsage.cpp │ ├── MsgPackSerializer │ │ ├── measure.cpp │ │ ├── CMakeLists.txt │ │ └── misc.cpp │ ├── Numbers │ │ ├── CMakeLists.txt │ │ └── decomposeFloat.cpp │ ├── JsonArrayConst │ │ ├── CMakeLists.txt │ │ ├── size.cpp │ │ ├── subscript.cpp │ │ ├── isNull.cpp │ │ ├── iterator.cpp │ │ └── nesting.cpp │ ├── JsonVariantConst │ │ ├── CMakeLists.txt │ │ ├── isnull.cpp │ │ ├── size.cpp │ │ └── nesting.cpp │ ├── JsonObjectConst │ │ ├── CMakeLists.txt │ │ ├── size.cpp │ │ ├── isNull.cpp │ │ ├── nesting.cpp │ │ ├── iterator.cpp │ │ └── subscript.cpp │ ├── JsonDocument │ │ ├── cast.cpp │ │ ├── swap.cpp │ │ ├── size.cpp │ │ ├── CMakeLists.txt │ │ ├── nesting.cpp │ │ ├── compare.cpp │ │ ├── isNull.cpp │ │ └── clear.cpp │ ├── TextFormatter │ │ ├── CMakeLists.txt │ │ └── writeString.cpp │ ├── JsonArray │ │ ├── CMakeLists.txt │ │ ├── unbound.cpp │ │ ├── size.cpp │ │ ├── isNull.cpp │ │ ├── iterator.cpp │ │ ├── nesting.cpp │ │ └── clear.cpp │ ├── JsonObject │ │ ├── CMakeLists.txt │ │ ├── unbound.cpp │ │ ├── clear.cpp │ │ ├── isNull.cpp │ │ ├── nesting.cpp │ │ ├── iterator.cpp │ │ └── size.cpp │ ├── JsonSerializer │ │ ├── CMakeLists.txt │ │ ├── misc.cpp │ │ └── CustomWriter.cpp │ ├── MsgPackDeserializer │ │ ├── CMakeLists.txt │ │ └── doubleToFloat.cpp │ ├── JsonDeserializer │ │ ├── CMakeLists.txt │ │ └── misc.cpp │ ├── IntegrationTests │ │ ├── CMakeLists.txt │ │ └── issue772.cpp │ ├── JsonVariant │ │ ├── CMakeLists.txt │ │ ├── size.cpp │ │ ├── nesting.cpp │ │ ├── clear.cpp │ │ └── nullptr.cpp │ ├── ResourceManager │ │ ├── CMakeLists.txt │ │ ├── clear.cpp │ │ ├── size.cpp │ │ └── StringBuffer.cpp │ ├── Cpp17 │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── ArduinoJsonConfig.cmake.in ├── ci │ ├── espidf │ │ ├── main │ │ │ ├── component.mk │ │ │ ├── CMakeLists.txt │ │ │ └── main.cpp │ │ └── CMakeLists.txt │ └── particle.sh ├── scripts │ ├── get-release-page.sh │ ├── publish-particle-library.sh │ ├── extract_changes.awk │ └── wandbox │ │ ├── publish.sh │ │ ├── JsonGeneratorExample.cpp │ │ └── JsonParserExample.cpp └── conf_test │ ├── x64.cpp │ ├── x86.cpp │ ├── esp8266.cpp │ └── avr.cpp ├── .mbedignore ├── .devcontainer ├── gcc12 │ ├── Dockerfile │ └── devcontainer.json ├── clang13 │ ├── Dockerfile │ └── devcontainer.json ├── clang14 │ ├── Dockerfile │ └── devcontainer.json ├── clang15 │ ├── Dockerfile │ └── devcontainer.json ├── clang16 │ ├── Dockerfile │ └── devcontainer.json ├── clang17 │ ├── Dockerfile │ └── devcontainer.json ├── gcc5 │ └── devcontainer.json ├── gcc6 │ └── devcontainer.json ├── gcc7 │ └── devcontainer.json ├── gcc8 │ └── devcontainer.json ├── gcc9 │ └── devcontainer.json ├── clang7 │ └── devcontainer.json ├── clang8 │ └── devcontainer.json ├── clang9 │ └── devcontainer.json ├── gcc10 │ └── devcontainer.json ├── gcc11 │ └── devcontainer.json ├── clang10 │ └── devcontainer.json ├── clang11 │ └── devcontainer.json ├── clang5 │ └── devcontainer.json ├── clang6 │ └── devcontainer.json └── gcc48 │ └── devcontainer.json ├── .github ├── FUNDING.yml ├── workflows │ └── lock.yml └── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.md │ ├── help.md │ └── bug_report.md ├── ArduinoJson.h ├── CONTRIBUTING.md ├── .gitignore ├── src ├── ArduinoJson │ ├── Polyfills │ │ ├── type_traits │ │ │ ├── declval.hpp │ │ │ ├── type_identity.hpp │ │ │ ├── is_pointer.hpp │ │ │ ├── is_const.hpp │ │ │ ├── is_same.hpp │ │ │ ├── void_t.hpp │ │ │ ├── is_array.hpp │ │ │ ├── integral_constant.hpp │ │ │ ├── is_floating_point.hpp │ │ │ ├── is_class.hpp │ │ │ ├── remove_const.hpp │ │ │ ├── enable_if.hpp │ │ │ ├── remove_reference.hpp │ │ │ ├── is_enum.hpp │ │ │ ├── conditional.hpp │ │ │ ├── remove_cv.hpp │ │ │ ├── decay.hpp │ │ │ ├── function_traits.hpp │ │ │ ├── is_unsigned.hpp │ │ │ ├── is_base_of.hpp │ │ │ ├── is_signed.hpp │ │ │ ├── is_convertible.hpp │ │ │ ├── is_integral.hpp │ │ │ └── make_unsigned.hpp │ │ ├── assert.hpp │ │ ├── ctype.hpp │ │ ├── math.hpp │ │ ├── alias_cast.hpp │ │ ├── mpl │ │ │ └── max.hpp │ │ ├── integer.hpp │ │ ├── utility.hpp │ │ ├── type_traits.hpp │ │ ├── limits.hpp │ │ ├── attributes.hpp │ │ └── preprocessor.hpp │ ├── version.hpp │ ├── Variant │ │ ├── VariantTag.hpp │ │ ├── Converter.hpp │ │ ├── VariantDataVisitor.hpp │ │ ├── JsonVariantCopier.hpp │ │ └── VariantAttorney.hpp │ ├── Numbers │ │ ├── JsonFloat.hpp │ │ └── JsonInteger.hpp │ ├── Serialization │ │ ├── Writers │ │ │ ├── DummyWriter.hpp │ │ │ ├── PrintWriter.hpp │ │ │ ├── StdStreamWriter.hpp │ │ │ ├── StaticStringWriter.hpp │ │ │ ├── StdStringWriter.hpp │ │ │ └── ArduinoStringWriter.hpp │ │ ├── measure.hpp │ │ ├── CountingDecorator.hpp │ │ └── Writer.hpp │ ├── Deserialization │ │ ├── Readers │ │ │ ├── ArduinoStringReader.hpp │ │ │ ├── VariantReader.hpp │ │ │ ├── StdStreamReader.hpp │ │ │ ├── ArduinoStreamReader.hpp │ │ │ ├── IteratorReader.hpp │ │ │ └── FlashReader.hpp │ │ ├── NestingLimit.hpp │ │ └── DeserializationOptions.hpp │ ├── Strings │ │ ├── IsString.hpp │ │ ├── StringAdapter.hpp │ │ └── Adapters │ │ │ └── StringObject.hpp │ ├── MsgPack │ │ ├── ieee754.hpp │ │ └── endianness.hpp │ ├── Json │ │ ├── EscapeSequence.hpp │ │ ├── Latch.hpp │ │ └── Utf8.hpp │ └── Memory │ │ ├── Allocator.hpp │ │ └── Alignment.hpp └── ArduinoJson.h ├── .clang-format ├── idf_component.yml ├── .vscode └── settings.json ├── library.properties ├── CMakeLists.txt ├── library.json ├── keywords.txt ├── SUPPORT.md ├── LICENSE.txt └── appveyor.yml /.prettierignore: -------------------------------------------------------------------------------- 1 | *.md 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.sh text eol=lf 3 | -------------------------------------------------------------------------------- /component.mk: -------------------------------------------------------------------------------- 1 | COMPONENT_ADD_INCLUDEDIRS := src 2 | -------------------------------------------------------------------------------- /extras/fuzzing/json_seed_corpus/EmptyArray.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /extras/fuzzing/json_seed_corpus/EmptyObject.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/fixint_positive: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /extras/particle/project.properties: -------------------------------------------------------------------------------- 1 | name=ArduinoJsonCI 2 | -------------------------------------------------------------------------------- /extras/fuzzing/json_corpus/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_corpus/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.mbedignore: -------------------------------------------------------------------------------- 1 | .devcontainer/ 2 | .github/ 3 | examples/ 4 | extras/ 5 | -------------------------------------------------------------------------------- /extras/fuzzing/json_seed_corpus/IntegerOverflow.json: -------------------------------------------------------------------------------- 1 | 9720730739393920739 2 | -------------------------------------------------------------------------------- /extras/tests/catch/.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true 2 | SortIncludes: false 3 | -------------------------------------------------------------------------------- /extras/tests/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: '-clang-analyzer-security.insecureAPI.*' 2 | -------------------------------------------------------------------------------- /extras/particle/src/smocktest.ino: -------------------------------------------------------------------------------- 1 | #include "ArduinoJson.h" 2 | 3 | void setup() {} 4 | 5 | void loop() {} 6 | -------------------------------------------------------------------------------- /.devcontainer/gcc12/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y cmake git g++-12 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: bblanchon 2 | custom: 3 | - https://arduinojson.org/book/ 4 | - https://donate.benoitblanchon.fr/ 5 | -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/nil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/nil -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/false: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/false -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/int16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/int16 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/int32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/int32 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/int64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/int64 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/int8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/int8 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/map16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/map16 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/map32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/map32 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/str16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/str16 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/str32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/str32 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/str8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/str8 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/true: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/true -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/uint8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/uint8 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/array16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/array16 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/array32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/array32 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/fixarray: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/fixarray -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/fixmap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/fixmap -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/fixstr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/fixstr -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/float32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/float32 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/float64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/float64 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/uint16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/uint16 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/uint32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/uint32 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/uint64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/uint64 -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_seed_corpus/fixint_negative: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bblanchon/ArduinoJson/HEAD/extras/fuzzing/msgpack_seed_corpus/fixint_negative -------------------------------------------------------------------------------- /ArduinoJson.h: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include "src/ArduinoJson.h" 6 | -------------------------------------------------------------------------------- /extras/fuzzing/json_seed_corpus/Strings.json: -------------------------------------------------------------------------------- 1 | [ 2 | "hello", 3 | 'hello', 4 | hello, 5 | {"hello":"world"}, 6 | {'hello':'world'}, 7 | {hello:world} 8 | ] -------------------------------------------------------------------------------- /extras/ArduinoJsonConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") 4 | check_required_components("@PROJECT_NAME@") 5 | -------------------------------------------------------------------------------- /.devcontainer/clang13/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y cmake git clang-13 libc++-13-dev libc++abi-13-dev 5 | ENV CC=clang-13 CXX=clang++-13 6 | -------------------------------------------------------------------------------- /.devcontainer/clang14/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y cmake git clang-14 libc++-14-dev libc++abi-14-dev 5 | ENV CC=clang-14 CXX=clang++-14 6 | -------------------------------------------------------------------------------- /.devcontainer/clang15/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y cmake git clang-15 libc++-15-dev libc++abi-15-dev 5 | ENV CC=clang-15 CXX=clang++-15 6 | -------------------------------------------------------------------------------- /.devcontainer/clang16/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y cmake git clang-16 libc++-16-dev libc++abi-16-dev 5 | ENV CC=clang-16 CXX=clang++-16 6 | -------------------------------------------------------------------------------- /.devcontainer/clang17/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | RUN apt-get update 4 | RUN apt-get install -y cmake git clang-17 libc++-17-dev libc++abi-17-dev 5 | ENV CC=clang-17 CXX=clang++-17 6 | -------------------------------------------------------------------------------- /extras/ci/espidf/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # "main" pseudo-component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | -------------------------------------------------------------------------------- /extras/tests/catch/catch.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright Benoit Blanchon 2014-2021 3 | // MIT License 4 | 5 | #define CATCH_CONFIG_MAIN 6 | #include "catch.hpp" 7 | -------------------------------------------------------------------------------- /extras/ci/espidf/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | idf_component_register( 6 | SRCS "main.cpp" 7 | INCLUDE_DIRS "" 8 | ) 9 | -------------------------------------------------------------------------------- /extras/ci/particle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ex 2 | 3 | BOARD=$1 4 | 5 | cd "$(dirname "$0")/../../" 6 | 7 | cp extras/particle/src/smocktest.ino src/ 8 | cp extras/particle/project.properties ./ 9 | 10 | particle compile "$BOARD" 11 | -------------------------------------------------------------------------------- /extras/ci/espidf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | cmake_minimum_required(VERSION 3.5) 6 | 7 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 8 | project(example) 9 | -------------------------------------------------------------------------------- /extras/fuzzing/json_seed_corpus/Comments.json: -------------------------------------------------------------------------------- 1 | //comment 2 | /*comment*/ 3 | [ //comment 4 | /*comment*/"comment"/*comment*/,//comment 5 | /*comment*/{//comment 6 | /* comment*/"key"//comment 7 | : //comment 8 | "value"//comment 9 | }/*comment*/ 10 | ]//comment -------------------------------------------------------------------------------- /extras/tests/FailingBuilds/assign_char.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | 7 | // See issue #1498 8 | 9 | int main() { 10 | JsonDocument doc; 11 | doc["dummy"] = 'A'; 12 | } 13 | -------------------------------------------------------------------------------- /extras/tests/FailingBuilds/deserialize_object.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | 7 | // See issue #2135 8 | 9 | int main() { 10 | JsonObject obj; 11 | deserializeJson(obj, ""); 12 | } 13 | -------------------------------------------------------------------------------- /extras/tests/FailingBuilds/variant_as_char.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | 7 | // See issue #1498 8 | 9 | int main() { 10 | JsonDocument doc; 11 | doc["dummy"].as(); 12 | } 13 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution to ArduinoJson 2 | 3 | First, thank you for taking the time to contribute to this project. 4 | 5 | You can submit changes via GitHub Pull Requests. 6 | 7 | Please: 8 | 9 | 1. Update the test suite for any change of behavior 10 | 2. Use clang-format in "file" mode to format the code 11 | -------------------------------------------------------------------------------- /extras/tests/FailingBuilds/Issue978.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | 7 | struct Stream {}; 8 | 9 | int main() { 10 | Stream* stream = 0; 11 | JsonDocument doc; 12 | deserializeJson(doc, stream); 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/lock.yml: -------------------------------------------------------------------------------- 1 | name: Lock Threads 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | 7 | jobs: 8 | lock: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: dessant/lock-threads@v5 12 | with: 13 | github-token: ${{ github.token }} 14 | issue-inactive-days: 30 15 | -------------------------------------------------------------------------------- /extras/tests/Misc/custom_string.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | struct custom_char_traits : std::char_traits {}; 10 | 11 | using custom_string = std::basic_string; 12 | -------------------------------------------------------------------------------- /extras/tests/Helpers/Arduino.h: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "api/Print.h" 8 | #include "api/Stream.h" 9 | #include "api/String.h" 10 | #include "avr/pgmspace.h" 11 | 12 | #define ARDUINO 13 | #define ARDUINO_H_INCLUDED 1 14 | -------------------------------------------------------------------------------- /extras/fuzzing/json_fuzzer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 4 | JsonDocument doc; 5 | DeserializationError error = deserializeJson(doc, data, size); 6 | if (!error) { 7 | std::string json; 8 | serializeJson(doc, json); 9 | } 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /extras/fuzzing/msgpack_fuzzer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 4 | JsonDocument doc; 5 | DeserializationError error = deserializeMsgPack(doc, data, size); 6 | if (!error) { 7 | std::string json; 8 | serializeMsgPack(doc, json); 9 | } 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /extras/tests/Helpers/Literals.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | // the space before _s is required by GCC 4.8 10 | inline std::string operator"" _s(const char* str, size_t len) { 11 | return std::string(str, len); 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.idea 3 | /build 4 | /bin 5 | /lib 6 | /sftp-config.json 7 | .tags 8 | .tags_sorted_by_file 9 | /extras/fuzzing/*_fuzzer 10 | /extras/fuzzing/*_fuzzer.options 11 | /extras/fuzzing/*_fuzzer_seed_corpus.zip 12 | .vs/ 13 | /out/ 14 | 15 | # Used by CI for Particle 16 | /src/*.ino 17 | /project.properties 18 | 19 | # Used by IDF 20 | /dist/ 21 | -------------------------------------------------------------------------------- /extras/scripts/get-release-page.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | VERSION="$1" 6 | CHANGELOG="$2" 7 | ARDUINOJSON_H="$3" 8 | 9 | cat << END 10 | --- 11 | branch: v7 12 | version: $VERSION 13 | date: '$(date +'%Y-%m-%d')' 14 | $(extras/scripts/wandbox/publish.sh "$ARDUINOJSON_H") 15 | --- 16 | 17 | $(extras/scripts/extract_changes.awk "$CHANGELOG") 18 | END 19 | -------------------------------------------------------------------------------- /extras/tests/MixedConfiguration/decode_unicode_1.cpp: -------------------------------------------------------------------------------- 1 | #define ARDUINOJSON_DECODE_UNICODE 1 2 | #include 3 | 4 | #include 5 | 6 | TEST_CASE("ARDUINOJSON_DECODE_UNICODE == 1") { 7 | JsonDocument doc; 8 | DeserializationError err = deserializeJson(doc, "\"\\uD834\\uDD1E\""); 9 | 10 | REQUIRE(err == DeserializationError::Ok); 11 | } 12 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/declval.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template 12 | T&& declval(); 13 | 14 | ARDUINOJSON_END_PRIVATE_NAMESPACE 15 | -------------------------------------------------------------------------------- /src/ArduinoJson/version.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #define ARDUINOJSON_VERSION "7.4.2" 8 | #define ARDUINOJSON_VERSION_MAJOR 7 9 | #define ARDUINOJSON_VERSION_MINOR 4 10 | #define ARDUINOJSON_VERSION_REVISION 2 11 | #define ARDUINOJSON_VERSION_MACRO V742 12 | -------------------------------------------------------------------------------- /extras/fuzzing/json_seed_corpus/Numbers.json: -------------------------------------------------------------------------------- 1 | [ 2 | 123, 3 | -123, 4 | 123.456, 5 | -123.456, 6 | 12e34, 7 | 12e-34, 8 | 12e+34, 9 | 12E34, 10 | 12E-34, 11 | 12E+34, 12 | 12.34e56, 13 | 12.34e-56, 14 | 12.34e+56, 15 | 12.34E56, 16 | 12.34E-56, 17 | 12.34E+56, 18 | NaN, 19 | -NaN, 20 | +NaN, 21 | Infinity, 22 | +Infinity, 23 | -Infinity 24 | ] -------------------------------------------------------------------------------- /src/ArduinoJson.h: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #ifdef __cplusplus 8 | 9 | # include "ArduinoJson.hpp" 10 | 11 | using namespace ArduinoJson; 12 | 13 | #else 14 | 15 | #error ArduinoJson requires a C++ compiler, please change file extension to .cc or .cpp 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/assert.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #if ARDUINOJSON_DEBUG 10 | # include 11 | # define ARDUINOJSON_ASSERT(X) assert(X) 12 | #else 13 | # define ARDUINOJSON_ASSERT(X) ((void)0) 14 | #endif 15 | -------------------------------------------------------------------------------- /extras/tests/Cpp20/smoke_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | TEST_CASE("C++20 smoke test") { 7 | JsonDocument doc; 8 | 9 | deserializeJson(doc, "{\"hello\":\"world\"}"); 10 | REQUIRE(doc["hello"] == "world"); 11 | 12 | std::string json; 13 | serializeJson(doc, json); 14 | REQUIRE(json == "{\"hello\":\"world\"}"); 15 | } 16 | -------------------------------------------------------------------------------- /extras/tests/Helpers/api/Stream.h: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | // Reproduces Arduino's Stream class 8 | class Stream // : public Print 9 | { 10 | public: 11 | virtual ~Stream() {} 12 | virtual int read() = 0; 13 | virtual size_t readBytes(char* buffer, size_t length) = 0; 14 | }; 15 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 2 | 3 | BasedOnStyle: Google 4 | Standard: c++11 5 | AllowShortFunctionsOnASingleLine: Empty 6 | IncludeBlocks: Preserve 7 | IndentPPDirectives: AfterHash 8 | DerivePointerAlignment: false 9 | 10 | # Always break after if to get accurate coverage 11 | AllowShortIfStatementsOnASingleLine: false 12 | AllowShortLoopsOnASingleLine: false 13 | -------------------------------------------------------------------------------- /.devcontainer/gcc5/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 5", 3 | "image": "conanio/gcc5", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc5" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/gcc6/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 6", 3 | "image": "conanio/gcc6", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc6" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/gcc7/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 7", 3 | "image": "conanio/gcc7", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc7" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/gcc8/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 8", 3 | "image": "conanio/gcc8", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc8" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/gcc9/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 9", 3 | "image": "conanio/gcc9", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc9" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/type_identity.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "integral_constant.hpp" 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template 12 | struct type_identity { 13 | using type = T; 14 | }; 15 | 16 | ARDUINOJSON_END_PRIVATE_NAMESPACE 17 | -------------------------------------------------------------------------------- /.devcontainer/clang7/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 7", 3 | "image": "conanio/clang7", 4 | "runArgs": [ 5 | "--name=ArduinoJson-clang7" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/clang8/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 8", 3 | "image": "conanio/clang8", 4 | "runArgs": [ 5 | "--name=ArduinoJson-clang8" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/clang9/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 9", 3 | "image": "conanio/clang9", 4 | "runArgs": [ 5 | "--name=ArduinoJson-clang9" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/gcc10/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 10", 3 | "image": "conanio/gcc10", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc10" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/gcc11/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 11", 3 | "image": "conanio/gcc11", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc11" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /extras/tests/Deprecated/shallowCopy.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | TEST_CASE("shallowCopy()") { 9 | JsonDocument doc1, doc2; 10 | doc1["b"] = "c"; 11 | doc2["a"].shallowCopy(doc1); 12 | 13 | REQUIRE(doc2.as() == "{\"a\":{\"b\":\"c\"}}"); 14 | } 15 | -------------------------------------------------------------------------------- /extras/tests/Misc/issue2181.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #define true 0x1 6 | #define false 0x0 7 | 8 | #include 9 | #include 10 | 11 | TEST_CASE("Issue #2181") { 12 | JsonDocument doc; 13 | doc["hello"] = "world"; 14 | REQUIRE(doc.as() == "{\"hello\":\"world\"}"); 15 | } 16 | -------------------------------------------------------------------------------- /extras/tests/MsgPackSerializer/measure.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | TEST_CASE("measureMsgPack()") { 9 | JsonDocument doc; 10 | JsonObject object = doc.to(); 11 | object["hello"] = "world"; 12 | 13 | REQUIRE(measureMsgPack(doc) == 13); 14 | } 15 | -------------------------------------------------------------------------------- /.devcontainer/clang10/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 10", 3 | "image": "conanio/clang10", 4 | "runArgs": [ 5 | "--name=ArduinoJson-clang10" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/clang11/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 11", 3 | "image": "conanio/clang11", 4 | "runArgs": [ 5 | "--name=ArduinoJson-clang11" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/clang5/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 5", 3 | "image": "conanio/clang50", 4 | "runArgs": [ 5 | "--name=ArduinoJson-clang5" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.devcontainer/clang6/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 6", 3 | "image": "conanio/clang60", 4 | "runArgs": [ 5 | "--name=ArduinoJson-clang6" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools" 11 | ], 12 | "settings": { 13 | "cmake.generator": "Unix Makefiles", 14 | "cmake.buildDirectory": "/tmp/build" 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/ArduinoJson/Variant/VariantTag.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | struct VariantTag {}; 12 | 13 | template 14 | struct IsVariant : is_base_of {}; 15 | 16 | ARDUINOJSON_END_PRIVATE_NAMESPACE 17 | -------------------------------------------------------------------------------- /extras/tests/MixedConfiguration/decode_unicode_0.cpp: -------------------------------------------------------------------------------- 1 | #define ARDUINOJSON_DECODE_UNICODE 0 2 | #include 3 | 4 | #include 5 | 6 | TEST_CASE("ARDUINOJSON_DECODE_UNICODE == 0") { 7 | JsonDocument doc; 8 | DeserializationError err = deserializeJson(doc, "\"\\uD834\\uDD1E\""); 9 | 10 | REQUIRE(err == DeserializationError::Ok); 11 | REQUIRE(doc.as() == "\\uD834\\uDD1E"); 12 | } 13 | -------------------------------------------------------------------------------- /.devcontainer/gcc12/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 12", 3 | "build": { 4 | "dockerfile": "Dockerfile", 5 | }, 6 | "runArgs": [ 7 | "--name=ArduinoJson-gcc12" 8 | ], 9 | "customizations": { 10 | "vscode": { 11 | "extensions": [ 12 | "ms-vscode.cmake-tools" 13 | ], 14 | "settings": { 15 | "cmake.generator": "Unix Makefiles", 16 | "cmake.buildDirectory": "/tmp/build" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /idf_component.yml: -------------------------------------------------------------------------------- 1 | version: "7.4.2" 2 | description: >- 3 | A simple and efficient JSON library for embedded C++. 4 | ★ 6953 stars on GitHub! 5 | Supports serialization, deserialization, MessagePack, streams, filtering, and more. 6 | Fully tested and documented. 7 | url: https://arduinojson.org/ 8 | files: 9 | exclude: 10 | - "**/.vs/**/*" 11 | - ".devcontainer/**/*" 12 | - "examples/**/*" 13 | - "extras/**/*" 14 | -------------------------------------------------------------------------------- /.devcontainer/clang13/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 13", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | "runArgs": [ 7 | "--name=ArduinoJson-clang13" 8 | ], 9 | "customizations": { 10 | "vscode": { 11 | "extensions": [ 12 | "ms-vscode.cmake-tools" 13 | ], 14 | "settings": { 15 | "cmake.generator": "Unix Makefiles", 16 | "cmake.buildDirectory": "/tmp/build" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.devcontainer/clang14/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 14", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | "runArgs": [ 7 | "--name=ArduinoJson-clang14" 8 | ], 9 | "customizations": { 10 | "vscode": { 11 | "extensions": [ 12 | "ms-vscode.cmake-tools" 13 | ], 14 | "settings": { 15 | "cmake.generator": "Unix Makefiles", 16 | "cmake.buildDirectory": "/tmp/build" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.devcontainer/clang15/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 15", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | "runArgs": [ 7 | "--name=ArduinoJson-clang15" 8 | ], 9 | "customizations": { 10 | "vscode": { 11 | "extensions": [ 12 | "ms-vscode.cmake-tools" 13 | ], 14 | "settings": { 15 | "cmake.generator": "Unix Makefiles", 16 | "cmake.buildDirectory": "/tmp/build" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.devcontainer/clang16/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 16", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | "runArgs": [ 7 | "--name=ArduinoJson-clang16" 8 | ], 9 | "customizations": { 10 | "vscode": { 11 | "extensions": [ 12 | "ms-vscode.cmake-tools" 13 | ], 14 | "settings": { 15 | "cmake.generator": "Unix Makefiles", 16 | "cmake.buildDirectory": "/tmp/build" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.devcontainer/clang17/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Clang 17", 3 | "build": { 4 | "dockerfile": "Dockerfile" 5 | }, 6 | "runArgs": [ 7 | "--name=ArduinoJson-clang17" 8 | ], 9 | "customizations": { 10 | "vscode": { 11 | "extensions": [ 12 | "ms-vscode.cmake-tools" 13 | ], 14 | "settings": { 15 | "cmake.generator": "Unix Makefiles", 16 | "cmake.buildDirectory": "/tmp/build" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /extras/tests/Misc/issue1967.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | // we expect ArduinoJson.h to include 6 | #define ARDUINOJSON_ENABLE_STD_STRING 1 7 | 8 | // but we don't want it to included accidentally 9 | #undef ARDUINO 10 | #define ARDUINOJSON_ENABLE_STD_STREAM 0 11 | #define ARDUINOJSON_ENABLE_STRING_VIEW 0 12 | 13 | #include 14 | -------------------------------------------------------------------------------- /extras/tests/Numbers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(NumbersTests 6 | convertNumber.cpp 7 | decomposeFloat.cpp 8 | parseDouble.cpp 9 | parseFloat.cpp 10 | parseInteger.cpp 11 | parseNumber.cpp 12 | ) 13 | 14 | add_test(Numbers NumbersTests) 15 | 16 | set_tests_properties(Numbers 17 | PROPERTIES 18 | LABELS "Catch" 19 | ) 20 | -------------------------------------------------------------------------------- /extras/tests/JsonArrayConst/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonArrayConstTests 6 | equals.cpp 7 | isNull.cpp 8 | iterator.cpp 9 | nesting.cpp 10 | size.cpp 11 | subscript.cpp 12 | ) 13 | 14 | add_test(JsonArrayConst JsonArrayConstTests) 15 | 16 | set_tests_properties(JsonArrayConst 17 | PROPERTIES 18 | LABELS "Catch" 19 | ) 20 | -------------------------------------------------------------------------------- /extras/tests/JsonVariantConst/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonVariantConstTests 6 | as.cpp 7 | is.cpp 8 | isnull.cpp 9 | nesting.cpp 10 | size.cpp 11 | subscript.cpp 12 | ) 13 | 14 | add_test(JsonVariantConst JsonVariantConstTests) 15 | 16 | set_tests_properties(JsonVariantConst 17 | PROPERTIES 18 | LABELS "Catch" 19 | ) 20 | -------------------------------------------------------------------------------- /extras/tests/MixedConfiguration/use_double_1.cpp: -------------------------------------------------------------------------------- 1 | #define ARDUINOJSON_USE_DOUBLE 1 2 | #include 3 | 4 | #include 5 | 6 | TEST_CASE("ARDUINOJSON_USE_DOUBLE == 1") { 7 | JsonDocument doc; 8 | JsonObject root = doc.to(); 9 | 10 | root["pi"] = 3.14; 11 | root["e"] = 2.72; 12 | 13 | std::string json; 14 | serializeJson(doc, json); 15 | 16 | REQUIRE(json == "{\"pi\":3.14,\"e\":2.72}"); 17 | } 18 | -------------------------------------------------------------------------------- /extras/ci/espidf/main/main.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | 7 | extern "C" void app_main() { 8 | char buffer[256]; 9 | JsonDocument doc; 10 | 11 | doc["hello"] = "world"; 12 | serializeJson(doc, buffer); 13 | deserializeJson(doc, buffer); 14 | serializeMsgPack(doc, buffer); 15 | deserializeMsgPack(doc, buffer); 16 | } 17 | -------------------------------------------------------------------------------- /extras/tests/JsonObjectConst/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonObjectConstTests 6 | equals.cpp 7 | isNull.cpp 8 | iterator.cpp 9 | nesting.cpp 10 | size.cpp 11 | subscript.cpp 12 | ) 13 | 14 | add_test(JsonObjectConst JsonObjectConstTests) 15 | 16 | set_tests_properties(JsonObjectConst 17 | PROPERTIES 18 | LABELS "Catch" 19 | ) 20 | -------------------------------------------------------------------------------- /extras/tests/FailingBuilds/write_long_long.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #define ARDUINOJSON_USE_LONG_LONG 0 6 | #include 7 | 8 | #if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8 9 | # error This test requires sizeof(long) < 8 10 | #endif 11 | 12 | int main() { 13 | JsonDocument doc; 14 | doc["dummy"] = static_cast(42); 15 | } 16 | -------------------------------------------------------------------------------- /extras/tests/JsonDocument/cast.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | TEST_CASE("Implicit cast to JsonVariant") { 11 | JsonDocument doc; 12 | 13 | doc["hello"] = "world"; 14 | 15 | JsonVariant var = doc; 16 | 17 | CHECK(var.as() == "{\"hello\":\"world\"}"); 18 | } 19 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "integral_constant.hpp" 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template 12 | struct is_pointer : false_type {}; 13 | 14 | template 15 | struct is_pointer : true_type {}; 16 | 17 | ARDUINOJSON_END_PRIVATE_NAMESPACE 18 | -------------------------------------------------------------------------------- /src/ArduinoJson/Numbers/JsonFloat.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE 11 | 12 | #if ARDUINOJSON_USE_DOUBLE 13 | using JsonFloat = double; 14 | #else 15 | using JsonFloat = float; 16 | #endif 17 | 18 | ARDUINOJSON_END_PUBLIC_NAMESPACE 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: 👨‍🏫 ArduinoJson Assistant 4 | url: https://arduinojson.org/v7/assistant/ 5 | about: An online tool that computes memory requirements and generates scaffolding code for your project. 6 | - name: 👨‍⚕️ ArduinoJson Troubleshooter 7 | url: https://arduinojson.org/v7/troubleshooter/ 8 | about: An online tool that helps you diagnose the most common issues with ArduinoJson. 9 | -------------------------------------------------------------------------------- /extras/tests/TextFormatter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(TextFormatterTests 6 | writeFloat.cpp 7 | writeInteger.cpp 8 | writeString.cpp 9 | ) 10 | 11 | set_target_properties(TextFormatterTests PROPERTIES UNITY_BUILD OFF) 12 | 13 | add_test(TextFormatter TextFormatterTests) 14 | 15 | set_tests_properties(TextFormatter 16 | PROPERTIES 17 | LABELS "Catch" 18 | ) 19 | -------------------------------------------------------------------------------- /.devcontainer/gcc48/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GCC 4.8", 3 | "image": "conanio/gcc48", 4 | "runArgs": [ 5 | "--name=ArduinoJson-gcc48" 6 | ], 7 | "customizations": { 8 | "vscode": { 9 | "extensions": [ 10 | "ms-vscode.cmake-tools", 11 | "josetr.cmake-language-support-vscode", 12 | "ms-vscode.cpptools" 13 | ], 14 | "settings": { 15 | "cmake.generator": "Unix Makefiles", 16 | "cmake.buildDirectory": "/tmp/build" 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /extras/tests/MsgPackSerializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(MsgPackSerializerTests 6 | destination_types.cpp 7 | measure.cpp 8 | misc.cpp 9 | serializeArray.cpp 10 | serializeObject.cpp 11 | serializeVariant.cpp 12 | ) 13 | 14 | add_test(MsgPackSerializer MsgPackSerializerTests) 15 | 16 | set_tests_properties(MsgPackSerializer 17 | PROPERTIES 18 | LABELS "Catch" 19 | ) 20 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/ctype.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | #ifndef isdigit 12 | inline bool isdigit(char c) { 13 | return '0' <= c && c <= '9'; 14 | } 15 | #endif 16 | 17 | inline bool issign(char c) { 18 | return '-' == c || c == '+'; 19 | } 20 | 21 | ARDUINOJSON_END_PRIVATE_NAMESPACE 22 | -------------------------------------------------------------------------------- /extras/tests/FailingBuilds/read_long_long.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #define ARDUINOJSON_USE_LONG_LONG 0 6 | #include 7 | 8 | #if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8 9 | # error This test requires sizeof(long) < 8 10 | #endif 11 | 12 | ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(long long) 13 | int main() { 14 | JsonDocument doc; 15 | doc["dummy"].as(); 16 | } 17 | -------------------------------------------------------------------------------- /extras/tests/MixedConfiguration/issue1707.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #define ARDUINO 6 | #define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) 7 | 8 | #include 9 | 10 | #include 11 | 12 | TEST_CASE("Issue1707") { 13 | JsonDocument doc; 14 | 15 | DeserializationError err = deserializeJson(doc, F("{\"hello\":12}")); 16 | REQUIRE(err == DeserializationError::Ok); 17 | } 18 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", 3 | "git.inputValidationLength": 80, 4 | "git.inputValidationSubjectLength": 72, 5 | "files.insertFinalNewline": true, 6 | "files.trimFinalNewlines": true, 7 | "search.exclude": { 8 | "/extras/tests/catch/*": true 9 | }, 10 | "C_Cpp.default.includePath": [ 11 | "/src" 12 | ], 13 | "[cmake]": { 14 | "editor.detectIndentation": false, 15 | "editor.insertSpaces": false, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /extras/tests/MixedConfiguration/use_long_long_1.cpp: -------------------------------------------------------------------------------- 1 | #define ARDUINOJSON_USE_LONG_LONG 1 2 | #include 3 | 4 | #include 5 | 6 | TEST_CASE("ARDUINOJSON_USE_LONG_LONG == 1") { 7 | JsonDocument doc; 8 | JsonObject root = doc.to(); 9 | 10 | root["A"] = 123456789123456789; 11 | root["B"] = 987654321987654321; 12 | 13 | std::string json; 14 | serializeJson(doc, json); 15 | 16 | REQUIRE(json == "{\"A\":123456789123456789,\"B\":987654321987654321}"); 17 | } 18 | -------------------------------------------------------------------------------- /src/ArduinoJson/Serialization/Writers/DummyWriter.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | class DummyWriter { 12 | public: 13 | size_t write(uint8_t) { 14 | return 1; 15 | } 16 | 17 | size_t write(const uint8_t*, size_t n) { 18 | return n; 19 | } 20 | }; 21 | 22 | ARDUINOJSON_END_PRIVATE_NAMESPACE 23 | -------------------------------------------------------------------------------- /extras/tests/catch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright Benoit Blanchon 2014-2021 3 | # MIT License 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | set(CMAKE_CXX_STANDARD_REQUIRED OFF) 7 | 8 | add_library(catch 9 | catch.hpp 10 | catch.cpp 11 | ) 12 | 13 | target_include_directories(catch 14 | PUBLIC 15 | ${CMAKE_CURRENT_SOURCE_DIR} 16 | ) 17 | 18 | if(MINGW) 19 | # prevent "too many sections (32837)" with MinGW 20 | target_compile_options(catch PRIVATE -Wa,-mbig-obj) 21 | endif() 22 | -------------------------------------------------------------------------------- /extras/tests/JsonArray/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonArrayTests 6 | add.cpp 7 | clear.cpp 8 | compare.cpp 9 | copyArray.cpp 10 | equals.cpp 11 | isNull.cpp 12 | iterator.cpp 13 | nesting.cpp 14 | remove.cpp 15 | size.cpp 16 | subscript.cpp 17 | unbound.cpp 18 | ) 19 | 20 | add_test(JsonArray JsonArrayTests) 21 | 22 | set_tests_properties(JsonArray 23 | PROPERTIES 24 | LABELS "Catch" 25 | ) 26 | -------------------------------------------------------------------------------- /extras/tests/JsonObject/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonObjectTests 6 | clear.cpp 7 | compare.cpp 8 | equals.cpp 9 | isNull.cpp 10 | iterator.cpp 11 | nesting.cpp 12 | remove.cpp 13 | set.cpp 14 | size.cpp 15 | std_string.cpp 16 | subscript.cpp 17 | unbound.cpp 18 | ) 19 | 20 | add_test(JsonObject JsonObjectTests) 21 | 22 | set_tests_properties(JsonObject 23 | PROPERTIES 24 | LABELS "Catch" 25 | ) 26 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/is_const.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "integral_constant.hpp" 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | // A meta-function that return the type T without the const modifier 12 | template 13 | struct is_const : false_type {}; 14 | 15 | template 16 | struct is_const : true_type {}; 17 | 18 | ARDUINOJSON_END_PRIVATE_NAMESPACE 19 | -------------------------------------------------------------------------------- /extras/tests/JsonSerializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonSerializerTests 6 | CustomWriter.cpp 7 | JsonArray.cpp 8 | JsonArrayPretty.cpp 9 | JsonObject.cpp 10 | JsonObjectPretty.cpp 11 | JsonVariant.cpp 12 | misc.cpp 13 | std_stream.cpp 14 | std_string.cpp 15 | ) 16 | 17 | add_test(JsonSerializer JsonSerializerTests) 18 | 19 | set_tests_properties(JsonSerializer 20 | PROPERTIES 21 | LABELS "Catch" 22 | ) 23 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/is_same.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "integral_constant.hpp" 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | // A meta-function that returns true if types T and U are the same. 12 | template 13 | struct is_same : false_type {}; 14 | 15 | template 16 | struct is_same : true_type {}; 17 | 18 | ARDUINOJSON_END_PRIVATE_NAMESPACE 19 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/void_t.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template 12 | struct make_void { 13 | using type = void; 14 | }; 15 | 16 | template 17 | using void_t = typename make_void::type; 18 | // NOTE: using void_t = void; doesn't work on GCC 4.8 19 | 20 | ARDUINOJSON_END_PRIVATE_NAMESPACE 21 | -------------------------------------------------------------------------------- /extras/tests/Deprecated/macros.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | TEST_CASE("JSON_ARRAY_SIZE") { 9 | REQUIRE(JSON_ARRAY_SIZE(10) == ArduinoJson::detail::sizeofArray(10)); 10 | } 11 | 12 | TEST_CASE("JSON_OBJECT_SIZE") { 13 | REQUIRE(JSON_OBJECT_SIZE(10) == ArduinoJson::detail::sizeofObject(10)); 14 | } 15 | 16 | TEST_CASE("JSON_STRING_SIZE") { 17 | REQUIRE(JSON_STRING_SIZE(10) == 11); // issue #2054 18 | } 19 | -------------------------------------------------------------------------------- /extras/tests/Misc/version.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | using Catch::Matchers::StartsWith; 10 | 11 | TEST_CASE("ARDUINOJSON_VERSION") { 12 | std::stringstream version; 13 | 14 | version << ARDUINOJSON_VERSION_MAJOR << "." << ARDUINOJSON_VERSION_MINOR 15 | << "." << ARDUINOJSON_VERSION_REVISION; 16 | 17 | REQUIRE_THAT(ARDUINOJSON_VERSION, StartsWith(version.str())); 18 | } 19 | -------------------------------------------------------------------------------- /extras/conf_test/x64.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG"); 4 | 5 | static_assert(ARDUINOJSON_SLOT_ID_SIZE == 4, "ARDUINOJSON_SLOT_ID_SIZE"); 6 | 7 | static_assert(ARDUINOJSON_POOL_CAPACITY == 256, "ARDUINOJSON_POOL_CAPACITY"); 8 | 9 | static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); 10 | 11 | static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); 12 | 13 | static_assert(sizeof(ArduinoJson::detail::VariantData) == 16, "slot size"); 14 | 15 | int main() {} 16 | -------------------------------------------------------------------------------- /extras/conf_test/x86.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG"); 4 | 5 | static_assert(ARDUINOJSON_SLOT_ID_SIZE == 2, "ARDUINOJSON_SLOT_ID_SIZE"); 6 | 7 | static_assert(ARDUINOJSON_POOL_CAPACITY == 128, "ARDUINOJSON_POOL_CAPACITY"); 8 | 9 | static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); 10 | 11 | static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); 12 | 13 | static_assert(sizeof(ArduinoJson::detail::VariantData) == 8, "slot size"); 14 | 15 | int main() {} 16 | -------------------------------------------------------------------------------- /extras/tests/MsgPackDeserializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(MsgPackDeserializerTests 6 | deserializeArray.cpp 7 | deserializeObject.cpp 8 | deserializeVariant.cpp 9 | destination_types.cpp 10 | doubleToFloat.cpp 11 | errors.cpp 12 | filter.cpp 13 | input_types.cpp 14 | nestingLimit.cpp 15 | ) 16 | 17 | add_test(MsgPackDeserializer MsgPackDeserializerTests) 18 | 19 | set_tests_properties(MsgPackDeserializer 20 | PROPERTIES 21 | LABELS "Catch" 22 | ) 23 | -------------------------------------------------------------------------------- /extras/tests/JsonDocument/swap.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | TEST_CASE("std::swap") { 10 | SECTION("JsonDocument*") { 11 | JsonDocument *p1, *p2; 12 | swap(p1, p2); // issue #1678 13 | } 14 | 15 | SECTION("JsonDocument") { 16 | JsonDocument doc1, doc2; 17 | doc1.set("hello"); 18 | doc2.set("world"); 19 | 20 | swap(doc1, doc2); 21 | 22 | CHECK(doc1.as() == "world"); 23 | CHECK(doc2.as() == "hello"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=ArduinoJson 2 | version=7.4.2 3 | author=Benoit Blanchon 4 | maintainer=Benoit Blanchon 5 | sentence=A simple and efficient JSON library for embedded C++. 6 | paragraph=⭐ 6953 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented. 7 | category=Data Processing 8 | url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties 9 | architectures=* 10 | repository=https://github.com/bblanchon/ArduinoJson.git 11 | license=MIT 12 | -------------------------------------------------------------------------------- /src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template 12 | struct Reader::value>> 13 | : BoundedReader { 14 | explicit Reader(const ::String& s) 15 | : BoundedReader(s.c_str(), s.length()) {} 16 | }; 17 | 18 | ARDUINOJSON_END_PRIVATE_NAMESPACE 19 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/is_array.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include // size_t 10 | 11 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 12 | 13 | template 14 | struct is_array : false_type {}; 15 | 16 | template 17 | struct is_array : true_type {}; 18 | 19 | template 20 | struct is_array : true_type {}; 21 | 22 | ARDUINOJSON_END_PRIVATE_NAMESPACE 23 | -------------------------------------------------------------------------------- /extras/tests/JsonVariantConst/isnull.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | TEST_CASE("JsonVariantConst::isNull()") { 9 | JsonDocument doc; 10 | JsonVariantConst variant = doc.to(); 11 | 12 | SECTION("returns true when undefined") { 13 | REQUIRE(variant.isNull() == true); 14 | } 15 | 16 | SECTION("returns false if value is integer") { 17 | doc.set(42); 18 | 19 | REQUIRE(variant.isNull() == false); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/ArduinoJson/Strings/IsString.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 11 | 12 | template 13 | struct IsString : false_type {}; 14 | 15 | template 16 | struct IsString::AdaptedString>> 17 | : true_type {}; 18 | 19 | ARDUINOJSON_END_PRIVATE_NAMESPACE 20 | -------------------------------------------------------------------------------- /extras/tests/JsonObjectConst/size.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | TEST_CASE("JsonObjectConst::size()") { 10 | JsonDocument doc; 11 | JsonObjectConst obj = doc.to(); 12 | 13 | SECTION("returns 0 when empty") { 14 | REQUIRE(0 == obj.size()); 15 | } 16 | 17 | SECTION("returns the number of members") { 18 | doc["hello"] = 1; 19 | doc["world"] = 2; 20 | REQUIRE(2 == obj.size()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /extras/tests/Misc/NoArduinoHeader.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #define ARDUINO 1 6 | #define ARDUINOJSON_ENABLE_PROGMEM 0 7 | #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 8 | #define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 9 | #define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 10 | #include 11 | 12 | #include 13 | 14 | TEST_CASE("Arduino.h") { 15 | #ifdef ARDUINO_H_INCLUDED 16 | FAIL("Arduino.h should not be included"); 17 | #else 18 | INFO("Arduino.h not included"); 19 | #endif 20 | } 21 | -------------------------------------------------------------------------------- /src/ArduinoJson/MsgPack/ieee754.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) { 12 | f[0] = uint8_t((d[0] & 0xC0) | (d[0] << 3 & 0x3f) | (d[1] >> 5)); 13 | f[1] = uint8_t((d[1] << 3) | (d[2] >> 5)); 14 | f[2] = uint8_t((d[2] << 3) | (d[3] >> 5)); 15 | f[3] = uint8_t((d[3] << 3) | (d[4] >> 5)); 16 | } 17 | 18 | ARDUINOJSON_END_PRIVATE_NAMESPACE 19 | -------------------------------------------------------------------------------- /extras/conf_test/esp8266.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static_assert(ARDUINOJSON_USE_LONG_LONG == 1, "ARDUINOJSON_USE_LONG_LONG"); 4 | 5 | static_assert(ARDUINOJSON_SLOT_ID_SIZE == 2, "ARDUINOJSON_SLOT_ID_SIZE"); 6 | 7 | static_assert(ARDUINOJSON_POOL_CAPACITY == 128, "ARDUINOJSON_POOL_CAPACITY"); 8 | 9 | static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); 10 | 11 | static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); 12 | 13 | static_assert(sizeof(ArduinoJson::detail::VariantData) == 8, "slot size"); 14 | 15 | void setup() {} 16 | void loop() {} 17 | -------------------------------------------------------------------------------- /extras/scripts/publish-particle-library.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eu 4 | 5 | SOURCE_DIR="$(dirname "$0")/../.." 6 | WORK_DIR=$(mktemp -d) 7 | trap 'rm -rf "$WORK_DIR"' EXIT 8 | 9 | cp "$SOURCE_DIR/README.md" "$WORK_DIR/README.md" 10 | cp "$SOURCE_DIR/CHANGELOG.md" "$WORK_DIR/CHANGELOG.md" 11 | cp "$SOURCE_DIR/library.properties" "$WORK_DIR/library.properties" 12 | cp "$SOURCE_DIR/LICENSE.txt" "$WORK_DIR/LICENSE.txt" 13 | cp -r "$SOURCE_DIR/src" "$WORK_DIR/" 14 | cp -r "$SOURCE_DIR/examples" "$WORK_DIR/" 15 | 16 | cd "$WORK_DIR" 17 | particle library upload 18 | particle library publish 19 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template 12 | struct integral_constant { 13 | static const T value = v; 14 | }; 15 | 16 | template 17 | using bool_constant = integral_constant; 18 | 19 | using true_type = bool_constant; 20 | using false_type = bool_constant; 21 | 22 | ARDUINOJSON_END_PRIVATE_NAMESPACE 23 | -------------------------------------------------------------------------------- /extras/tests/Misc/issue2166.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | struct CCLASS { 9 | static const char mszKey[]; 10 | }; 11 | 12 | TEST_CASE("Issue #2166") { 13 | JsonDocument doc; 14 | doc[CCLASS::mszKey] = 12; 15 | REQUIRE(doc.as() == "{\"test3\":12}"); 16 | 17 | JsonObject obj = doc.to(); 18 | obj[CCLASS::mszKey] = 12; 19 | REQUIRE(doc.as() == "{\"test3\":12}"); 20 | } 21 | 22 | const char CCLASS::mszKey[] = "test3"; 23 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/is_floating_point.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "integral_constant.hpp" 8 | #include "is_same.hpp" 9 | #include "remove_cv.hpp" 10 | 11 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 12 | 13 | template 14 | struct is_floating_point 15 | : integral_constant>::value || 17 | is_same>::value> {}; 18 | 19 | ARDUINOJSON_END_PRIVATE_NAMESPACE 20 | -------------------------------------------------------------------------------- /extras/tests/JsonDocument/size.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | TEST_CASE("JsonDocument::size()") { 9 | JsonDocument doc; 10 | 11 | SECTION("returns 0") { 12 | REQUIRE(doc.size() == 0); 13 | } 14 | 15 | SECTION("as an array, return 2") { 16 | doc.add(1); 17 | doc.add(2); 18 | 19 | REQUIRE(doc.size() == 2); 20 | } 21 | 22 | SECTION("as an object, return 2") { 23 | doc["a"] = 1; 24 | doc["b"] = 2; 25 | 26 | REQUIRE(doc.size() == 2); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/ArduinoJson/Deserialization/Readers/VariantReader.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | 10 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 11 | 12 | template 13 | struct Reader::value>> 14 | : Reader { 15 | explicit Reader(const TVariant& x) 16 | : Reader(x.template as()) {} 17 | }; 18 | 19 | ARDUINOJSON_END_PRIVATE_NAMESPACE 20 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/math.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | // Some libraries #define isnan() and isinf() so we need to check before 12 | // using this name 13 | 14 | #ifndef isnan 15 | template 16 | bool isnan(T x) { 17 | return x != x; 18 | } 19 | #endif 20 | 21 | #ifndef isinf 22 | template 23 | bool isinf(T x) { 24 | return x != 0.0 && x * 2 == x; 25 | } 26 | #endif 27 | ARDUINOJSON_END_PRIVATE_NAMESPACE 28 | -------------------------------------------------------------------------------- /extras/fuzzing/json_seed_corpus/ExcessiveNesting.json: -------------------------------------------------------------------------------- 1 | [1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20,[21,[22,[23,[24,[25,[26,[27,[28,[29,[30,[31,[32,[33,[34,[35,[36,[37,[38,[39,[40,[41,[42,[43,[44,[45,[46,[47,[48,[49,[50,[51,[52,[53,[54,[55,[56,[57,[58,[59,[60,[61,[62,[63,[64,[65,[66,[67,[68,[69,[70,[71,[72,[73,[74,[75,[76,[77,[78,[79,[80,[81,[82,[83,[84,[85,[86,[87,[88,[89,[90,[91,[92,[93,[94,[95,[96,[97,[98,[99,[100,[101,[102,[103,[104,[105,[106,[107,[108,[109,[110,[111,[112,[113,[114,[115,[116,[117,[118,[119,[120]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /extras/scripts/extract_changes.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | 3 | # Start echoing after the first list item 4 | /\* / { 5 | STARTED=1 6 | EMPTY_LINE=0 7 | } 8 | 9 | # Remember if we have seen an empty line 10 | /^[[:space:]]*$/ { 11 | EMPTY_LINE=1 12 | } 13 | 14 | # Exit when seeing a new version number 15 | /^v[[:digit:]]/ { 16 | if (STARTED) exit 17 | } 18 | 19 | # Print if the line is not empty 20 | # and restore the empty line we have skipped 21 | !/^[[:space:]]*$/ { 22 | if (STARTED) { 23 | if (EMPTY_LINE) { 24 | print "" 25 | EMPTY_LINE=0 26 | } 27 | print 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /extras/tests/JsonDeserializer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonDeserializerTests 6 | array.cpp 7 | DeserializationError.cpp 8 | destination_types.cpp 9 | errors.cpp 10 | filter.cpp 11 | input_types.cpp 12 | misc.cpp 13 | nestingLimit.cpp 14 | number.cpp 15 | object.cpp 16 | string.cpp 17 | ) 18 | 19 | set_target_properties(JsonDeserializerTests PROPERTIES UNITY_BUILD OFF) 20 | 21 | add_test(JsonDeserializer JsonDeserializerTests) 22 | 23 | set_tests_properties(JsonDeserializer 24 | PROPERTIES 25 | LABELS "Catch" 26 | ) 27 | -------------------------------------------------------------------------------- /extras/tests/Helpers/CustomReader.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | class CustomReader { 10 | std::stringstream stream_; 11 | 12 | public: 13 | CustomReader(const char* input) : stream_(input) {} 14 | CustomReader(const CustomReader&) = delete; 15 | 16 | int read() { 17 | return stream_.get(); 18 | } 19 | 20 | size_t readBytes(char* buffer, size_t length) { 21 | stream_.read(buffer, static_cast(length)); 22 | return static_cast(stream_.gcount()); 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /extras/tests/IntegrationTests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(IntegrationTests 6 | gbathree.cpp 7 | issue772.cpp 8 | round_trip.cpp 9 | openweathermap.cpp 10 | ) 11 | 12 | if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6) 13 | target_compile_options(IntegrationTests 14 | PUBLIC 15 | -fsingle-precision-constant # issue 544 16 | ) 17 | endif() 18 | 19 | add_test(IntegrationTests IntegrationTests) 20 | 21 | set_tests_properties(IntegrationTests 22 | PROPERTIES 23 | LABELS "Catch" 24 | ) 25 | -------------------------------------------------------------------------------- /extras/tests/JsonDocument/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonDocumentTests 6 | add.cpp 7 | assignment.cpp 8 | cast.cpp 9 | clear.cpp 10 | compare.cpp 11 | constructor.cpp 12 | ElementProxy.cpp 13 | isNull.cpp 14 | issue1120.cpp 15 | MemberProxy.cpp 16 | nesting.cpp 17 | overflowed.cpp 18 | remove.cpp 19 | set.cpp 20 | shrinkToFit.cpp 21 | size.cpp 22 | subscript.cpp 23 | swap.cpp 24 | ) 25 | 26 | add_test(JsonDocument JsonDocumentTests) 27 | 28 | set_tests_properties(JsonDocument 29 | PROPERTIES 30 | LABELS "Catch" 31 | ) 32 | -------------------------------------------------------------------------------- /extras/tests/JsonVariant/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(JsonVariantTests 6 | add.cpp 7 | as.cpp 8 | clear.cpp 9 | compare.cpp 10 | converters.cpp 11 | copy.cpp 12 | is.cpp 13 | isnull.cpp 14 | misc.cpp 15 | nesting.cpp 16 | nullptr.cpp 17 | or.cpp 18 | overflow.cpp 19 | remove.cpp 20 | set.cpp 21 | size.cpp 22 | stl_containers.cpp 23 | subscript.cpp 24 | types.cpp 25 | unbound.cpp 26 | ) 27 | 28 | add_test(JsonVariant JsonVariantTests) 29 | 30 | set_tests_properties(JsonVariant 31 | PROPERTIES 32 | LABELS "Catch" 33 | ) 34 | -------------------------------------------------------------------------------- /src/ArduinoJson/Variant/Converter.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE 10 | 11 | template 12 | struct Converter; 13 | 14 | ARDUINOJSON_END_PUBLIC_NAMESPACE 15 | 16 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 17 | 18 | // clang-format off 19 | template 20 | class InvalidConversion; // Error here? See https://arduinojson.org/v7/invalid-conversion/ 21 | // clang-format on 22 | 23 | ARDUINOJSON_END_PRIVATE_NAMESPACE 24 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/is_class.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "declval.hpp" 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template 12 | struct is_class { 13 | protected: // <- to avoid GCC's "all member functions in class are private" 14 | template 15 | static int probe(void (U::*)(void)); 16 | template 17 | static char probe(...); 18 | 19 | public: 20 | static const bool value = sizeof(probe(0)) == sizeof(int); 21 | }; 22 | 23 | ARDUINOJSON_END_PRIVATE_NAMESPACE 24 | -------------------------------------------------------------------------------- /extras/tests/ResourceManager/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | add_executable(ResourceManagerTests 6 | allocVariant.cpp 7 | clear.cpp 8 | saveString.cpp 9 | shrinkToFit.cpp 10 | size.cpp 11 | StringBuffer.cpp 12 | StringBuilder.cpp 13 | swap.cpp 14 | ) 15 | 16 | add_compile_definitions(ResourceManagerTests 17 | ARDUINOJSON_SLOT_ID_SIZE=1 # require less RAM for overflow tests 18 | ARDUINOJSON_POOL_CAPACITY=16 19 | ) 20 | 21 | add_test(ResourceManager ResourceManagerTests) 22 | 23 | set_tests_properties(ResourceManager 24 | PROPERTIES 25 | LABELS "Catch" 26 | ) 27 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/remove_const.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | // A meta-function that return the type T without the const modifier 12 | template 13 | struct remove_const { 14 | using type = T; 15 | }; 16 | template 17 | struct remove_const { 18 | using type = T; 19 | }; 20 | 21 | template 22 | using remove_const_t = typename remove_const::type; 23 | 24 | ARDUINOJSON_END_PRIVATE_NAMESPACE 25 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/enable_if.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | // A meta-function that return the type T if Condition is true. 12 | template 13 | struct enable_if {}; 14 | 15 | template 16 | struct enable_if { 17 | using type = T; 18 | }; 19 | 20 | template 21 | using enable_if_t = typename enable_if::type; 22 | 23 | ARDUINOJSON_END_PRIVATE_NAMESPACE 24 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | cmake_minimum_required(VERSION 3.15) 6 | 7 | if(ESP_PLATFORM) 8 | # Build ArduinoJson as an ESP-IDF component 9 | idf_component_register(INCLUDE_DIRS src) 10 | return() 11 | endif() 12 | 13 | project(ArduinoJson VERSION 7.4.2) 14 | 15 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) 16 | include(CTest) 17 | endif() 18 | 19 | add_subdirectory(src) 20 | 21 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) 22 | include(extras/CompileOptions.cmake) 23 | add_subdirectory(extras/tests) 24 | add_subdirectory(extras/fuzzing) 25 | endif() 26 | -------------------------------------------------------------------------------- /extras/conf_test/avr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static_assert(ARDUINOJSON_ENABLE_PROGMEM == 1, "ARDUINOJSON_ENABLE_PROGMEM"); 4 | 5 | static_assert(ARDUINOJSON_USE_LONG_LONG == 0, "ARDUINOJSON_USE_LONG_LONG"); 6 | 7 | static_assert(ARDUINOJSON_SLOT_ID_SIZE == 1, "ARDUINOJSON_SLOT_ID_SIZE"); 8 | 9 | static_assert(ARDUINOJSON_POOL_CAPACITY == 16, "ARDUINOJSON_POOL_CAPACITY"); 10 | 11 | static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); 12 | 13 | static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE"); 14 | 15 | static_assert(sizeof(ArduinoJson::detail::VariantData) == 6, "slot size"); 16 | 17 | void setup() {} 18 | void loop() {} 19 | -------------------------------------------------------------------------------- /extras/tests/JsonArray/unbound.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | using namespace Catch::Matchers; 9 | 10 | TEST_CASE("Unbound JsonArray") { 11 | JsonArray array; 12 | 13 | SECTION("SubscriptFails") { 14 | REQUIRE(array[0].isNull()); 15 | } 16 | 17 | SECTION("AddFails") { 18 | array.add(1); 19 | REQUIRE(0 == array.size()); 20 | } 21 | 22 | SECTION("PrintToWritesBrackets") { 23 | char buffer[32]; 24 | serializeJson(array, buffer, sizeof(buffer)); 25 | REQUIRE_THAT(buffer, Equals("null")); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /extras/tests/JsonObject/unbound.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | using namespace Catch::Matchers; 9 | 10 | TEST_CASE("Unbound JsonObject") { 11 | JsonObject obj; 12 | 13 | SECTION("retrieve member") { 14 | REQUIRE(obj["key"].isNull()); 15 | } 16 | 17 | SECTION("add member") { 18 | obj["hello"] = "world"; 19 | REQUIRE(0 == obj.size()); 20 | } 21 | 22 | SECTION("serialize") { 23 | char buffer[32]; 24 | serializeJson(obj, buffer, sizeof(buffer)); 25 | REQUIRE_THAT(buffer, Equals("null")); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | // A meta-function that return the type T without the reference modifier. 12 | template 13 | struct remove_reference { 14 | using type = T; 15 | }; 16 | template 17 | struct remove_reference { 18 | using type = T; 19 | }; 20 | 21 | template 22 | using remove_reference_t = typename remove_reference::type; 23 | 24 | ARDUINOJSON_END_PRIVATE_NAMESPACE 25 | -------------------------------------------------------------------------------- /extras/tests/JsonObject/clear.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | TEST_CASE("JsonObject::clear()") { 9 | SECTION("No-op on null JsonObject") { 10 | JsonObject obj; 11 | obj.clear(); 12 | REQUIRE(obj.isNull() == true); 13 | REQUIRE(obj.size() == 0); 14 | } 15 | 16 | SECTION("Removes all elements") { 17 | JsonDocument doc; 18 | JsonObject obj = doc.to(); 19 | obj["hello"] = 1; 20 | obj["world"] = 2; 21 | obj.clear(); 22 | REQUIRE(obj.size() == 0); 23 | REQUIRE(obj.isNull() == false); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/alias_cast.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | #include // for size_t 9 | 10 | #include 11 | #include "math.hpp" 12 | 13 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 14 | 15 | template 16 | struct alias_cast_t { 17 | union { 18 | F raw; 19 | T data; 20 | }; 21 | }; 22 | 23 | template 24 | T alias_cast(F raw_data) { 25 | alias_cast_t ac; 26 | ac.raw = raw_data; 27 | return ac.data; 28 | } 29 | 30 | ARDUINOJSON_END_PRIVATE_NAMESPACE 31 | -------------------------------------------------------------------------------- /extras/tests/JsonArrayConst/size.cpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #include 6 | #include 7 | 8 | TEST_CASE("JsonArrayConst::size()") { 9 | JsonDocument doc; 10 | JsonArrayConst array = doc.to(); 11 | 12 | SECTION("returns 0 if unbound") { 13 | JsonArrayConst unbound; 14 | REQUIRE(0U == unbound.size()); 15 | } 16 | 17 | SECTION("returns 0 is empty") { 18 | REQUIRE(0U == array.size()); 19 | } 20 | 21 | SECTION("return number of elements") { 22 | doc.add("hello"); 23 | doc.add("world"); 24 | 25 | REQUIRE(2U == array.size()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/type_traits/is_enum.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include "is_class.hpp" 8 | #include "is_convertible.hpp" 9 | #include "is_floating_point.hpp" 10 | #include "is_integral.hpp" 11 | #include "is_same.hpp" 12 | 13 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 14 | 15 | template 16 | struct is_enum { 17 | static const bool value = is_convertible::value && 18 | !is_class::value && !is_integral::value && 19 | !is_floating_point::value; 20 | }; 21 | 22 | ARDUINOJSON_END_PRIVATE_NAMESPACE 23 | -------------------------------------------------------------------------------- /extras/tests/Cpp17/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | if(MSVC_VERSION LESS 1910) 6 | return() 7 | endif() 8 | 9 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) 10 | return() 11 | endif() 12 | 13 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7) 14 | return() 15 | endif() 16 | 17 | set(CMAKE_CXX_STANDARD 17) 18 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 19 | 20 | add_executable(Cpp17Tests 21 | string_view.cpp 22 | ) 23 | 24 | add_test(Cpp17 Cpp17Tests) 25 | 26 | set_tests_properties(Cpp17 27 | PROPERTIES 28 | LABELS "Catch" 29 | ) 30 | -------------------------------------------------------------------------------- /extras/tests/Cpp20/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ArduinoJson - https://arduinojson.org 2 | # Copyright © 2014-2025, Benoit BLANCHON 3 | # MIT License 4 | 5 | if(MSVC_VERSION LESS 1910) 6 | return() 7 | endif() 8 | 9 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10) 10 | return() 11 | endif() 12 | 13 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10) 14 | return() 15 | endif() 16 | 17 | set(CMAKE_CXX_STANDARD 20) 18 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 19 | 20 | add_executable(Cpp20Tests 21 | smoke_test.cpp 22 | ) 23 | 24 | add_test(Cpp20 Cpp20Tests) 25 | 26 | set_tests_properties(Cpp20 27 | PROPERTIES 28 | LABELS "Catch" 29 | ) 30 | -------------------------------------------------------------------------------- /extras/tests/MixedConfiguration/enable_nan_0.cpp: -------------------------------------------------------------------------------- 1 | #define ARDUINOJSON_ENABLE_NAN 0 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | TEST_CASE("ARDUINOJSON_ENABLE_NAN == 0") { 8 | JsonDocument doc; 9 | JsonObject root = doc.to(); 10 | 11 | SECTION("serializeJson()") { 12 | root["X"] = std::numeric_limits::signaling_NaN(); 13 | 14 | std::string json; 15 | serializeJson(doc, json); 16 | 17 | REQUIRE(json == "{\"X\":null}"); 18 | } 19 | 20 | SECTION("deserializeJson()") { 21 | DeserializationError err = deserializeJson(doc, "{\"X\":NaN}"); 22 | 23 | REQUIRE(err == DeserializationError::InvalidInput); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ArduinoJson/Polyfills/mpl/max.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | #include // for size_t 10 | 11 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 12 | 13 | // A meta-function that returns the highest value 14 | template Y)> 15 | struct Max {}; 16 | 17 | template 18 | struct Max { 19 | static const size_t value = X; 20 | }; 21 | 22 | template 23 | struct Max { 24 | static const size_t value = Y; 25 | }; 26 | 27 | ARDUINOJSON_END_PRIVATE_NAMESPACE 28 | -------------------------------------------------------------------------------- /src/ArduinoJson/Serialization/measure.hpp: -------------------------------------------------------------------------------- 1 | // ArduinoJson - https://arduinojson.org 2 | // Copyright © 2014-2025, Benoit BLANCHON 3 | // MIT License 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE 10 | 11 | template