forked from bblanchon/ArduinoJson
@ -1,6 +1,11 @@
|
|||||||
ArduinoJson: change log
|
ArduinoJson: change log
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
HEAD
|
||||||
|
----
|
||||||
|
|
||||||
|
* Improve error messages when using `char` or `char*` (issue #2043)
|
||||||
|
|
||||||
v7.0.2 (2024-01-19)
|
v7.0.2 (2024-01-19)
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
|||||||
|
|
||||||
template <typename T, typename Enable>
|
template <typename T, typename Enable>
|
||||||
struct Converter {
|
struct Converter {
|
||||||
|
static_assert(!detail::is_same<T, char>::value,
|
||||||
|
"type 'char' is not supported, use 'signed char', 'unsigned "
|
||||||
|
"char' or another integer type instead");
|
||||||
|
|
||||||
static void toJson(const T& src, JsonVariant dst) {
|
static void toJson(const T& src, JsonVariant dst) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
convertToJson(src, dst); // Error here? See https://arduinojson.org/v7/unsupported-set/
|
convertToJson(src, dst); // Error here? See https://arduinojson.org/v7/unsupported-set/
|
||||||
@ -28,6 +32,9 @@ struct Converter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static T fromJson(JsonVariantConst src) {
|
static T fromJson(JsonVariantConst src) {
|
||||||
|
static_assert(!detail::is_same<T, char*>::value,
|
||||||
|
"type 'char*' is not supported, use 'const char*' instead");
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
T result; // Error here? See https://arduinojson.org/v7/non-default-constructible/
|
T result; // Error here? See https://arduinojson.org/v7/non-default-constructible/
|
||||||
convertFromJson(src, result); // Error here? See https://arduinojson.org/v7/unsupported-as/
|
convertFromJson(src, result); // Error here? See https://arduinojson.org/v7/unsupported-as/
|
||||||
@ -36,6 +43,9 @@ struct Converter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool checkJson(JsonVariantConst src) {
|
static bool checkJson(JsonVariantConst src) {
|
||||||
|
static_assert(!detail::is_same<T, char*>::value,
|
||||||
|
"type 'char*' is not supported, use 'const char*' instead");
|
||||||
|
|
||||||
T dummy = T();
|
T dummy = T();
|
||||||
// clang-format off
|
// clang-format off
|
||||||
return canConvertFromJson(src, dummy); // Error here? See https://arduinojson.org/v7/unsupported-is/
|
return canConvertFromJson(src, dummy); // Error here? See https://arduinojson.org/v7/unsupported-is/
|
||||||
|
@ -91,10 +91,8 @@ class VariantRefBase : public VariantTag {
|
|||||||
// Returns true if the value is of the specified type.
|
// Returns true if the value is of the specified type.
|
||||||
// https://arduinojson.org/v7/api/jsonvariant/is/
|
// https://arduinojson.org/v7/api/jsonvariant/is/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FORCE_INLINE typename enable_if<!ConverterNeedsWriteableRef<T>::value &&
|
FORCE_INLINE
|
||||||
!is_same<T, char*>::value &&
|
typename enable_if<!ConverterNeedsWriteableRef<T>::value, bool>::type
|
||||||
!is_same<T, char>::value,
|
|
||||||
bool>::type
|
|
||||||
is() const {
|
is() const {
|
||||||
return Converter<T>::checkJson(getVariantConst());
|
return Converter<T>::checkJson(getVariantConst());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user