Update to v6.21.5

This commit is contained in:
2024-02-02 08:27:48 +01:00
parent 9794ba24b2
commit 4f304aadef
17 changed files with 118 additions and 37 deletions

View File

@@ -1,6 +1,20 @@
ArduinoJson: change log ArduinoJson: change log
======================= =======================
v6.21.5 (2024-01-10)
-------
* Fix warning `function returns incomplete class type` on IAR (issue #2001)
* Fix `volatile bool` serialized as `1` or `0` instead of `true` or `false` (issue #2029)
* Remove unused files in the PlatformIO package
v6.21.4 (2023-12-07)
-------
* Fix error `'std::string' has not been declared` (issue #1967)
* Fix error `'std::string_view' has not been declared` (issue #1967)
* Fix error `no instance of overloaded function...` on recent IAR compilers (issue #2001)
v6.21.3 (2023-07-23) v6.21.3 (2023-07-23)
------- -------

View File

@@ -10,7 +10,7 @@ if(ESP_PLATFORM)
return() return()
endif() endif()
project(ArduinoJson VERSION 6.21.3) project(ArduinoJson VERSION 6.21.5)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest) include(CTest)

View File

@@ -8,9 +8,9 @@
[![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![Continuous Integration](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
[![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/6.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x) [![Coveralls branch](https://img.shields.io/coveralls/github/bblanchon/ArduinoJson/6.x?logo=coveralls)](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
[![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.21.3&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.21.3) [![Arduino Library Manager](https://img.shields.io/static/v1?label=Arduino&message=v6.21.5&logo=arduino&logoColor=white&color=blue)](https://www.ardu-badge.com/ArduinoJson/6.21.5)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.21.3)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.21.3) [![PlatformIO Registry](https://badges.registry.platformio.org/packages/bblanchon/library/ArduinoJson.svg?version=6.21.5)](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.21.5)
[![ESP IDF](https://img.shields.io/static/v1?label=ESP+IDF&message=v6.21.3&logo=cpu&logoColor=white&color=blue)](https://components.espressif.com/components/bblanchon/arduinojson) [![ESP IDF](https://img.shields.io/static/v1?label=ESP+IDF&message=v6.21.5&logo=cpu&logoColor=white&color=blue)](https://components.espressif.com/components/bblanchon/arduinojson)
[![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github&color=orange)](https://github.com/bblanchon/ArduinoJson/stargazers) [![GitHub stars](https://img.shields.io/github/stars/bblanchon/ArduinoJson?style=flat&logo=github&color=orange)](https://github.com/bblanchon/ArduinoJson/stargazers)
[![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github&color=orange)](https://github.com/sponsors/bblanchon) [![GitHub Sponsors](https://img.shields.io/github/sponsors/bblanchon?logo=github&color=orange)](https://github.com/sponsors/bblanchon)

View File

@@ -1,4 +1,4 @@
version: 6.21.3.{build} version: 6.21.5.{build}
environment: environment:
matrix: matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022

View File

@@ -1,8 +1,16 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
// we expect ArduinoJson.h to include <string_view>
// but we don't want it to included accidentally
#undef ARDUINO
#define ARDUINOJSON_ENABLE_STD_STREAM 0
#define ARDUINOJSON_ENABLE_STD_STRING 0
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <catch.hpp> #include <catch.hpp>
#include <string_view>
#if !ARDUINOJSON_ENABLE_STRING_VIEW #if !ARDUINOJSON_ENABLE_STRING_VIEW
# error ARDUINOJSON_ENABLE_STRING_VIEW must be set to 1 # error ARDUINOJSON_ENABLE_STRING_VIEW must be set to 1
#endif #endif
@@ -19,7 +27,7 @@ TEST_CASE("string_view") {
SECTION("JsonDocument::set()") { SECTION("JsonDocument::set()") {
doc.set(std::string_view("123", 2)); doc.set(std::string_view("123", 2));
REQUIRE(doc.as<std::string>() == "12"); REQUIRE(doc.as<std::string_view>() == "12");
} }
SECTION("JsonDocument::operator[]() const") { SECTION("JsonDocument::operator[]() const") {

View File

@@ -158,6 +158,11 @@ void convertToJson(char c, JsonVariant var) {
char buf[] = {c, 0}; char buf[] = {c, 0};
var.set(buf); var.set(buf);
} }
void convertFromJson(JsonVariantConst src, char& dst) {
auto p = src.as<const char*>();
dst = p ? p[0] : 0;
}
} // namespace ArduinoJson } // namespace ArduinoJson
TEST_CASE("Convert char to string") { // issue #1922 TEST_CASE("Convert char to string") { // issue #1922
@@ -165,3 +170,9 @@ TEST_CASE("Convert char to string") { // issue #1922
doc.set('a'); doc.set('a');
REQUIRE(doc.as<std::string>() == "a"); REQUIRE(doc.as<std::string>() == "a");
} }
TEST_CASE("Convert string to char") { // issue #1963
StaticJsonDocument<64> doc;
doc.set("a");
REQUIRE(doc.as<char>() == 'a');
}

View File

@@ -140,6 +140,13 @@ TEST_CASE("volatile") {
DynamicJsonDocument doc(4096); DynamicJsonDocument doc(4096);
JsonVariant variant = doc.to<JsonVariant>(); JsonVariant variant = doc.to<JsonVariant>();
SECTION("volatile bool") { // issue #2029
volatile bool f = true;
variant.set(f);
CHECK(variant.is<bool>() == true);
CHECK(variant.as<bool>() == true);
}
SECTION("volatile int") { SECTION("volatile int") {
volatile int f = 42; volatile int f = 42;
variant.set(f); variant.set(f);

View File

@@ -6,6 +6,7 @@ add_executable(MiscTests
arithmeticCompare.cpp arithmeticCompare.cpp
conflicts.cpp conflicts.cpp
FloatParts.cpp FloatParts.cpp
issue1967.cpp
JsonString.cpp JsonString.cpp
NoArduinoHeader.cpp NoArduinoHeader.cpp
printable.cpp printable.cpp

View File

@@ -0,0 +1,13 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
// we expect ArduinoJson.h to include <string>
#define ARDUINOJSON_ENABLE_STD_STRING 1
// but we don't want it to included accidentally
#undef ARDUINO
#define ARDUINOJSON_ENABLE_STD_STREAM 0
#define ARDUINOJSON_ENABLE_STRING_VIEW 0
#include <ArduinoJson.h>

View File

@@ -1,4 +1,4 @@
version: "6.21.3" version: "6.21.5"
description: >- description: >-
A simple and efficient JSON library for embedded C++. A simple and efficient JSON library for embedded C++.
ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ fixed allocation, ✔ zero-copy, ✔ streams, ✔ filtering, and more. ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ fixed allocation, ✔ zero-copy, ✔ streams, ✔ filtering, and more.

View File

@@ -7,16 +7,14 @@
"type": "git", "type": "git",
"url": "https://github.com/bblanchon/ArduinoJson.git" "url": "https://github.com/bblanchon/ArduinoJson.git"
}, },
"version": "6.21.3", "version": "6.21.5",
"authors": { "authors": {
"name": "Benoit Blanchon", "name": "Benoit Blanchon",
"url": "https://blog.benoitblanchon.fr" "url": "https://blog.benoitblanchon.fr"
}, },
"exclude": [ "export": {
".devcontainer", "include": ["src", "examples", "LICENSE.txt", "ArduinoJson.h"]
".github", },
"extras"
],
"frameworks": "*", "frameworks": "*",
"platforms": "*", "platforms": "*",
"build": { "build": {

View File

@@ -1,5 +1,5 @@
name=ArduinoJson name=ArduinoJson
version=6.21.3 version=6.21.5
author=Benoit Blanchon <blog.benoitblanchon.fr> author=Benoit Blanchon <blog.benoitblanchon.fr>
maintainer=Benoit Blanchon <blog.benoitblanchon.fr> maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
sentence=A simple and efficient JSON library for embedded C++. sentence=A simple and efficient JSON library for embedded C++.

View File

@@ -8,6 +8,7 @@
#include <string.h> // strcmp #include <string.h> // strcmp
#include <ArduinoJson/Polyfills/assert.hpp> #include <ArduinoJson/Polyfills/assert.hpp>
#include <ArduinoJson/Polyfills/attributes.hpp>
#include <ArduinoJson/Strings/StoragePolicy.hpp> #include <ArduinoJson/Strings/StoragePolicy.hpp>
#include <ArduinoJson/Strings/StringAdapter.hpp> #include <ArduinoJson/Strings/StringAdapter.hpp>
@@ -27,7 +28,7 @@ class ZeroTerminatedRamString {
return !str_; return !str_;
} }
size_t size() const { FORCE_INLINE size_t size() const {
return str_ ? ::strlen(str_) : 0; return str_ ? ::strlen(str_) : 0;
} }

View File

@@ -8,6 +8,14 @@
#include <ArduinoJson/Variant/JsonVariantConst.hpp> #include <ArduinoJson/Variant/JsonVariantConst.hpp>
#include <ArduinoJson/Variant/VariantFunctions.hpp> #include <ArduinoJson/Variant/VariantFunctions.hpp>
#if ARDUINOJSON_ENABLE_STD_STRING
# include <string>
#endif
#if ARDUINOJSON_ENABLE_STRING_VIEW
# include <string_view>
#endif
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
template <typename T, typename Enable> template <typename T, typename Enable>

View File

@@ -110,6 +110,13 @@ inline JsonVariant VariantRefBase<TDerived>::add() const {
variantAddElement(getOrCreateData(), getPool())); variantAddElement(getOrCreateData(), getPool()));
} }
template <typename TDerived>
template <typename T>
inline typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type
VariantRefBase<TDerived>::as() const {
return Converter<T>::fromJson(getVariant());
}
template <typename TDerived> template <typename TDerived>
inline JsonVariant VariantRefBase<TDerived>::getVariant() const { inline JsonVariant VariantRefBase<TDerived>::getVariant() const {
return JsonVariant(getPool(), getData()); return JsonVariant(getPool(), getData());
@@ -120,6 +127,30 @@ inline JsonVariant VariantRefBase<TDerived>::getOrCreateVariant() const {
return JsonVariant(getPool(), getOrCreateData()); return JsonVariant(getPool(), getOrCreateData());
} }
template <typename TDerived>
template <typename T>
inline typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type
VariantRefBase<TDerived>::is() const {
return Converter<T>::checkJson(getVariant());
}
template <typename TDerived>
template <typename T>
inline bool VariantRefBase<TDerived>::set(const T& value) const {
Converter<typename detail::remove_cv<T>::type>::toJson(value,
getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
template <typename TDerived>
template <typename T>
inline bool VariantRefBase<TDerived>::set(T* value) const {
Converter<T*>::toJson(value, getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
template <typename TDerived> template <typename TDerived>
template <typename T> template <typename T>
inline typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type inline typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type

View File

@@ -57,11 +57,10 @@ class VariantRefBase : public VariantTag {
// https://arduinojson.org/v6/api/jsonvariant/as/ // https://arduinojson.org/v6/api/jsonvariant/as/
template <typename T> template <typename T>
FORCE_INLINE typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type FORCE_INLINE typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type
as() const { as() const;
return Converter<T>::fromJson(getVariant());
}
template <typename T> template <typename T,
typename = typename enable_if<!is_same<T, TDerived>::value>::type>
FORCE_INLINE operator T() const { FORCE_INLINE operator T() const {
return as<T>(); return as<T>();
} }
@@ -91,9 +90,7 @@ class VariantRefBase : public VariantTag {
template <typename T> template <typename T>
FORCE_INLINE FORCE_INLINE
typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type
is() const { is() const;
return Converter<T>::checkJson(getVariant());
}
// Returns true if the value is of the specified type. // Returns true if the value is of the specified type.
// https://arduinojson.org/v6/api/jsonvariant/is/ // https://arduinojson.org/v6/api/jsonvariant/is/
@@ -122,20 +119,12 @@ class VariantRefBase : public VariantTag {
// Copies the specified value. // Copies the specified value.
// https://arduinojson.org/v6/api/jsonvariant/set/ // https://arduinojson.org/v6/api/jsonvariant/set/
template <typename T> template <typename T>
FORCE_INLINE bool set(const T& value) const { FORCE_INLINE bool set(const T& value) const;
Converter<T>::toJson(value, getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
// Copies the specified value. // Copies the specified value.
// https://arduinojson.org/v6/api/jsonvariant/set/ // https://arduinojson.org/v6/api/jsonvariant/set/
template <typename T> template <typename T>
FORCE_INLINE bool set(T* value) const { FORCE_INLINE bool set(T* value) const;
Converter<T*>::toJson(value, getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
// Returns the size of the array or object. // Returns the size of the array or object.
// https://arduinojson.org/v6/api/jsonvariant/size/ // https://arduinojson.org/v6/api/jsonvariant/size/

View File

@@ -4,8 +4,8 @@
#pragma once #pragma once
#define ARDUINOJSON_VERSION "6.21.3" #define ARDUINOJSON_VERSION "6.21.5"
#define ARDUINOJSON_VERSION_MAJOR 6 #define ARDUINOJSON_VERSION_MAJOR 6
#define ARDUINOJSON_VERSION_MINOR 21 #define ARDUINOJSON_VERSION_MINOR 21
#define ARDUINOJSON_VERSION_REVISION 3 #define ARDUINOJSON_VERSION_REVISION 5
#define ARDUINOJSON_VERSION_MACRO V6213 #define ARDUINOJSON_VERSION_MACRO V6215