mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-06-25 09:21:34 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
733bc4ee82 | |||
9aa77994b4 | |||
f051f8328d | |||
411424b74e | |||
5e5c287978 | |||
377cf63075 |
93
.github/workflows/ci.yml
vendored
93
.github/workflows/ci.yml
vendored
@ -93,44 +93,40 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- clang: "3.9"
|
||||
runner: ubuntu-20.04
|
||||
archive: bionic
|
||||
- clang: "4.0"
|
||||
runner: ubuntu-20.04
|
||||
archive: bionic
|
||||
- clang: "5.0"
|
||||
runner: ubuntu-20.04
|
||||
archive: bionic
|
||||
- clang: "6.0"
|
||||
runner: ubuntu-20.04
|
||||
archive: bionic
|
||||
- clang: "7"
|
||||
runner: ubuntu-20.04
|
||||
runner: ubuntu-22.04
|
||||
archive: focal
|
||||
- clang: "8"
|
||||
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
|
||||
runner: ubuntu-20.04
|
||||
runner: ubuntu-22.04
|
||||
archive: focal
|
||||
- clang: "9"
|
||||
cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
|
||||
runner: ubuntu-20.04
|
||||
runner: ubuntu-22.04
|
||||
archive: focal
|
||||
- clang: "10"
|
||||
cxxflags: -fsanitize=address -fno-sanitize-recover=all
|
||||
runner: ubuntu-20.04
|
||||
runner: ubuntu-22.04
|
||||
archive: focal
|
||||
- clang: "11"
|
||||
runner: ubuntu-22.04
|
||||
- clang: "12"
|
||||
runner: ubuntu-22.04
|
||||
- clang: "13"
|
||||
runner: ubuntu-22.04
|
||||
- clang: "14"
|
||||
runner: ubuntu-22.04
|
||||
- clang: "15"
|
||||
runner: ubuntu-22.04
|
||||
runs-on: ${{ matrix.runner }}
|
||||
- clang: 14
|
||||
- clang: 15
|
||||
- clang: 16
|
||||
- clang: 17
|
||||
- clang: 18
|
||||
- clang: 19
|
||||
runs-on: ${{ matrix.runner || 'ubuntu-latest' }}
|
||||
steps:
|
||||
- name: Add archive repositories
|
||||
if: matrix.archive
|
||||
run: |
|
||||
sudo gpg --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
|
||||
sudo gpg --export 3B4FE6ACC0B21F32 | sudo tee /etc/apt/trusted.gpg.d/ubuntu-keyring.gpg > /dev/null
|
||||
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ ${{ matrix.archive }} main'
|
||||
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ ${{ matrix.archive }} universe'
|
||||
- name: Install Clang ${{ matrix.clang }}
|
||||
@ -138,10 +134,9 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y clang-${{ matrix.clang }}
|
||||
- name: Install libc++ ${{ matrix.clang }}
|
||||
if: matrix.clang >= 11
|
||||
run: sudo apt-get install -y libc++-${{ matrix.clang }}-dev libc++abi-${{ matrix.clang }}-dev
|
||||
- name: Install libunwind ${{ matrix.clang }}
|
||||
if: matrix.clang == 12 # dependency is missing in Ubuntu 22.04
|
||||
if: matrix.clang == 12 # dependency is missing in Ubuntu 22.04
|
||||
run: sudo apt-get install -y libunwind-${{ matrix.clang }}-dev
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@ -163,7 +158,7 @@ jobs:
|
||||
conf_test:
|
||||
name: Test configuration on Linux
|
||||
needs: [gcc, clang]
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Install
|
||||
run: |
|
||||
@ -257,7 +252,7 @@ jobs:
|
||||
board: arduino:avr:uno
|
||||
- core: arduino:samd
|
||||
board: arduino:samd:mkr1000
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@ -412,7 +407,7 @@ jobs:
|
||||
arm:
|
||||
name: GCC for ARM processor
|
||||
needs: gcc
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Install
|
||||
run: |
|
||||
@ -431,7 +426,7 @@ jobs:
|
||||
coverage:
|
||||
needs: gcc
|
||||
name: Coverage
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Install
|
||||
run: sudo apt-get install -y lcov ninja-build
|
||||
@ -463,7 +458,7 @@ jobs:
|
||||
valgrind:
|
||||
needs: gcc
|
||||
name: Valgrind
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Install
|
||||
run: |
|
||||
@ -485,24 +480,24 @@ jobs:
|
||||
clang-tidy:
|
||||
needs: clang
|
||||
name: Clang-Tidy
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install
|
||||
run: sudo apt-get install -y clang-tidy cmake ninja-build
|
||||
run: sudo apt-get install -y clang-tidy libc++-dev libc++abi-dev
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Configure
|
||||
run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy-10;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
|
||||
run: cmake -G Ninja -DCMAKE_CXX_CLANG_TIDY="clang-tidy;--warnings-as-errors=*" -DCMAKE_BUILD_TYPE=Debug .
|
||||
env:
|
||||
CC: clang-10
|
||||
CXX: clang++-10
|
||||
CC: clang
|
||||
CXX: clang++
|
||||
- name: Check
|
||||
run: cmake --build . -- -k 0
|
||||
|
||||
amalgamate:
|
||||
needs: gcc
|
||||
name: Amalgamate ArduinoJson.h
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@ -578,7 +573,7 @@ jobs:
|
||||
|
||||
codeql:
|
||||
name: CodeQL
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
needs: gcc
|
||||
|
||||
permissions:
|
||||
@ -587,20 +582,20 @@ jobs:
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: cpp
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: cpp
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug .
|
||||
cmake --build .
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug .
|
||||
cmake --build .
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:cpp"
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:cpp"
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
jobs:
|
||||
release:
|
||||
name: Create release
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Set variables
|
||||
id: init
|
||||
|
@ -1,6 +1,11 @@
|
||||
ArduinoJson: change log
|
||||
=======================
|
||||
|
||||
v7.4.2 (2025-06-20)
|
||||
------
|
||||
|
||||
* Fix truncated strings on Arduino Due (issue #2181)
|
||||
|
||||
v7.4.1 (2025-04-11)
|
||||
------
|
||||
|
||||
|
@ -10,7 +10,7 @@ if(ESP_PLATFORM)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(ArduinoJson VERSION 7.4.1)
|
||||
project(ArduinoJson VERSION 7.4.2)
|
||||
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
include(CTest)
|
||||
|
@ -80,7 +80,7 @@ ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
|
||||
* Continuously tested on
|
||||
* [Visual Studio 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/7.x)
|
||||
* [GCC 4.8, 5, 6, 7, 8, 9, 10, 11, 12](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
||||
* [Clang 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10, 11, 12, 13, 14, 15](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
||||
* [Clang 7 to 19](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
||||
* [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
|
||||
* Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/)
|
||||
* Well documented
|
||||
@ -139,11 +139,6 @@ See the [tutorial on arduinojson.org](https://arduinojson.org/v7/doc/serializati
|
||||
|
||||
ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it!
|
||||
|
||||
<p>
|
||||
<a href="https://www.programmingelectronics.com/" rel="sponsored">
|
||||
<img src="https://arduinojson.org/images/2021/10/programmingeleactronicsacademy.png" alt="Programming Electronics Academy" width="200">
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/1technophile" rel="sponsored">
|
||||
<img alt="1technophile" src="https://avatars.githubusercontent.com/u/12672732?s=40&v=4">
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 7.4.1.{build}
|
||||
version: 7.4.2.{build}
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||
|
@ -69,6 +69,8 @@ TEST_CASE("JsonDocument assignment") {
|
||||
doc2 = std::move(doc1);
|
||||
|
||||
REQUIRE(doc2.as<std::string>() == "{\"hello\":\"world\"}");
|
||||
|
||||
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
|
||||
REQUIRE(doc1.as<std::string>() == "null");
|
||||
}
|
||||
REQUIRE(spyingAllocator.log() == AllocatorLog{
|
||||
|
@ -44,6 +44,8 @@ TEST_CASE("JsonDocument constructor") {
|
||||
JsonDocument doc2(std::move(doc1));
|
||||
|
||||
REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
|
||||
|
||||
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
|
||||
REQUIRE(doc1.as<std::string>() == "null");
|
||||
}
|
||||
REQUIRE(spyingAllocator.log() == AllocatorLog{
|
||||
|
@ -29,3 +29,23 @@ set_tests_properties(Misc
|
||||
PROPERTIES
|
||||
LABELS "Catch"
|
||||
)
|
||||
|
||||
add_executable(Issue2181
|
||||
issue2181.cpp # Cannot be linked with other tests
|
||||
)
|
||||
|
||||
set_target_properties(Issue2181 PROPERTIES UNITY_BUILD OFF)
|
||||
|
||||
add_test(Issue2181 Issue2181)
|
||||
|
||||
set_tests_properties(Issue2181
|
||||
PROPERTIES
|
||||
LABELS "Catch"
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(Issue2181
|
||||
PRIVATE
|
||||
-Wno-keyword-macro # keyword is hidden by macro definition
|
||||
)
|
||||
endif()
|
||||
|
15
extras/tests/Misc/issue2181.cpp
Normal file
15
extras/tests/Misc/issue2181.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2025, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#define true 0x1
|
||||
#define false 0x0
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("Issue #2181") {
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
|
||||
}
|
@ -116,12 +116,12 @@ TEST_CASE("StringBuilder") {
|
||||
}
|
||||
}
|
||||
|
||||
static JsonString saveString(StringBuilder& builder, const char* s) {
|
||||
static VariantData saveString(StringBuilder& builder, const char* s) {
|
||||
VariantData data;
|
||||
builder.startString();
|
||||
builder.append(s);
|
||||
builder.save(&data);
|
||||
return data.asString();
|
||||
return data;
|
||||
}
|
||||
|
||||
TEST_CASE("StringBuilder::save() deduplicates strings") {
|
||||
@ -134,9 +134,9 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
|
||||
auto s2 = saveString(builder, "world");
|
||||
auto s3 = saveString(builder, "hello");
|
||||
|
||||
REQUIRE(s1 == "hello");
|
||||
REQUIRE(s2 == "world");
|
||||
REQUIRE(+s1.c_str() == +s3.c_str()); // same address
|
||||
REQUIRE(s1.asString() == "hello");
|
||||
REQUIRE(s2.asString() == "world");
|
||||
REQUIRE(+s1.asString().c_str() == +s3.asString().c_str()); // same address
|
||||
|
||||
REQUIRE(spy.log() ==
|
||||
AllocatorLog{
|
||||
@ -152,9 +152,10 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
|
||||
auto s1 = saveString(builder, "hello world");
|
||||
auto s2 = saveString(builder, "hello");
|
||||
|
||||
REQUIRE(s1 == "hello world");
|
||||
REQUIRE(s2 == "hello");
|
||||
REQUIRE(+s2.c_str() != +s1.c_str()); // different address
|
||||
REQUIRE(s1.asString() == "hello world");
|
||||
REQUIRE(s2.asString() == "hello");
|
||||
REQUIRE(+s2.asString().c_str() !=
|
||||
+s1.asString().c_str()); // different address
|
||||
|
||||
REQUIRE(spy.log() ==
|
||||
AllocatorLog{
|
||||
@ -169,9 +170,10 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
|
||||
auto s1 = saveString(builder, "hello world");
|
||||
auto s2 = saveString(builder, "worl");
|
||||
|
||||
REQUIRE(s1 == "hello world");
|
||||
REQUIRE(s2 == "worl");
|
||||
REQUIRE(s2.c_str() != s1.c_str()); // different address
|
||||
REQUIRE(s1.asString() == "hello world");
|
||||
REQUIRE(s2.asString() == "worl");
|
||||
REQUIRE(s2.asString().c_str() !=
|
||||
s1.asString().c_str()); // different address
|
||||
|
||||
REQUIRE(spy.log() ==
|
||||
AllocatorLog{
|
||||
|
@ -1,7 +1,7 @@
|
||||
version: "7.4.1"
|
||||
version: "7.4.2"
|
||||
description: >-
|
||||
A simple and efficient JSON library for embedded C++.
|
||||
★ 6898 stars on GitHub!
|
||||
★ 6953 stars on GitHub!
|
||||
Supports serialization, deserialization, MessagePack, streams, filtering, and more.
|
||||
Fully tested and documented.
|
||||
url: https://arduinojson.org/
|
||||
|
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "ArduinoJson",
|
||||
"keywords": "json, rest, http, web",
|
||||
"description": "A simple and efficient JSON library for embedded C++. ⭐ 6898 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.",
|
||||
"description": "A simple and efficient JSON library for embedded C++. ⭐ 6953 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.",
|
||||
"homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bblanchon/ArduinoJson.git"
|
||||
},
|
||||
"version": "7.4.1",
|
||||
"version": "7.4.2",
|
||||
"authors": {
|
||||
"name": "Benoit Blanchon",
|
||||
"url": "https://blog.benoitblanchon.fr"
|
||||
|
@ -1,9 +1,9 @@
|
||||
name=ArduinoJson
|
||||
version=7.4.1
|
||||
version=7.4.2
|
||||
author=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
sentence=A simple and efficient JSON library for embedded C++.
|
||||
paragraph=⭐ 6898 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.
|
||||
paragraph=⭐ 6953 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.
|
||||
category=Data Processing
|
||||
url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties
|
||||
architectures=*
|
||||
|
@ -26,6 +26,15 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Remove true and false macros defined by some cores, such as Arduino Due's
|
||||
// See issues #2181 and arduino/ArduinoCore-sam#50
|
||||
#ifdef true
|
||||
# undef true
|
||||
#endif
|
||||
#ifdef false
|
||||
# undef false
|
||||
#endif
|
||||
|
||||
#include "ArduinoJson/Array/JsonArray.hpp"
|
||||
#include "ArduinoJson/Object/JsonObject.hpp"
|
||||
#include "ArduinoJson/Variant/JsonVariantConst.hpp"
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define ARDUINOJSON_VERSION "7.4.1"
|
||||
#define ARDUINOJSON_VERSION "7.4.2"
|
||||
#define ARDUINOJSON_VERSION_MAJOR 7
|
||||
#define ARDUINOJSON_VERSION_MINOR 4
|
||||
#define ARDUINOJSON_VERSION_REVISION 1
|
||||
#define ARDUINOJSON_VERSION_MACRO V741
|
||||
#define ARDUINOJSON_VERSION_REVISION 2
|
||||
#define ARDUINOJSON_VERSION_MACRO V742
|
||||
|
Reference in New Issue
Block a user