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