DynamicJsonDocument reallocates memory pool is it's too small

This commit is contained in:
Benoit Blanchon
2018-12-07 10:38:58 +01:00
parent b77b203935
commit e20c47c57b
3 changed files with 103 additions and 60 deletions

View File

@@ -63,6 +63,9 @@ class JsonDocument : public Visitable {
}
protected:
JsonDocument(MemoryPool pool)
: nestingLimit(ARDUINOJSON_DEFAULT_NESTING_LIMIT), _pool(pool) {}
JsonDocument(char* buf, size_t capa)
: nestingLimit(ARDUINOJSON_DEFAULT_NESTING_LIMIT), _pool(buf, capa) {}
@@ -71,6 +74,10 @@ class JsonDocument : public Visitable {
to<VariantRef>().set(src.as<VariantRef>());
}
void replacePool(MemoryPool pool) {
_pool = pool;
}
private:
VariantRef getVariant() {
return VariantRef(&_pool, &_data);