mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Mer isArray() and isArrayStrict() (6796,5602)
This commit is contained in:
@@ -183,7 +183,7 @@ struct Converter<ArrayConstRef> {
|
|||||||
|
|
||||||
static bool checkJson(VariantConstRef src) {
|
static bool checkJson(VariantConstRef src) {
|
||||||
const VariantData* data = getData(src);
|
const VariantData* data = getData(src);
|
||||||
return data && data->isArray();
|
return data && data->resolve()->isArray();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ struct Converter<ArrayRef> {
|
|||||||
|
|
||||||
static bool checkJson(VariantRef src) {
|
static bool checkJson(VariantRef src) {
|
||||||
VariantData* data = getData(src);
|
VariantData* data = getData(src);
|
||||||
return data && data->isArrayStrict();
|
return data && data->isArray();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace ARDUINOJSON_NAMESPACE
|
} // namespace ARDUINOJSON_NAMESPACE
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class VariantData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CollectionData *asArray() {
|
CollectionData *asArray() {
|
||||||
return isArrayStrict() ? &_content.asCollection : 0;
|
return isArray() ? &_content.asCollection : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CollectionData *asArray() const {
|
const CollectionData *asArray() const {
|
||||||
@@ -108,13 +108,6 @@ class VariantData {
|
|||||||
bool copyFrom(const VariantData &src, MemoryPool *pool);
|
bool copyFrom(const VariantData &src, MemoryPool *pool);
|
||||||
|
|
||||||
bool isArray() const {
|
bool isArray() const {
|
||||||
if (isPointer()) // P+0 G+0
|
|
||||||
return _content.asPointer->isArray();
|
|
||||||
else
|
|
||||||
return isArrayStrict();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isArrayStrict() const {
|
|
||||||
return (_flags & VALUE_IS_ARRAY) != 0;
|
return (_flags & VALUE_IS_ARRAY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +160,7 @@ class VariantData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void remove(size_t index) {
|
void remove(size_t index) {
|
||||||
if (isArrayStrict())
|
if (isArray())
|
||||||
_content.asCollection.removeElement(index);
|
_content.asCollection.removeElement(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +278,7 @@ class VariantData {
|
|||||||
VariantData *addElement(MemoryPool *pool) {
|
VariantData *addElement(MemoryPool *pool) {
|
||||||
if (isNull())
|
if (isNull())
|
||||||
toArray();
|
toArray();
|
||||||
if (!isArrayStrict())
|
if (!isArray())
|
||||||
return 0;
|
return 0;
|
||||||
return _content.asCollection.addElement(pool);
|
return _content.asCollection.addElement(pool);
|
||||||
}
|
}
|
||||||
@@ -298,7 +291,7 @@ class VariantData {
|
|||||||
VariantData *getOrAddElement(size_t index, MemoryPool *pool) {
|
VariantData *getOrAddElement(size_t index, MemoryPool *pool) {
|
||||||
if (isNull())
|
if (isNull())
|
||||||
toArray();
|
toArray();
|
||||||
if (!isArrayStrict())
|
if (!isArray())
|
||||||
return 0;
|
return 0;
|
||||||
return _content.asCollection.getOrAddElement(index, pool);
|
return _content.asCollection.getOrAddElement(index, pool);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user