AsyncJson: add option to init with root as json array
ref: https://github.com/bblanchon/ArduinoJson/issues/272
This commit is contained in:
parent
59732a09bd
commit
d74a84455f
|
@ -55,16 +55,18 @@ class AsyncJsonResponse: public AsyncAbstractResponse {
|
||||||
JsonVariant _root;
|
JsonVariant _root;
|
||||||
bool _isValid;
|
bool _isValid;
|
||||||
public:
|
public:
|
||||||
AsyncJsonResponse(): _isValid{false} {
|
AsyncJsonResponse(bool isArray): _isValid{false} {
|
||||||
_code = 200;
|
_code = 200;
|
||||||
_contentType = "text/json";
|
_contentType = "text/json";
|
||||||
|
if(isArray)
|
||||||
|
_root = _jsonBuffer.createArray();
|
||||||
|
else
|
||||||
_root = _jsonBuffer.createObject();
|
_root = _jsonBuffer.createObject();
|
||||||
}
|
}
|
||||||
~AsyncJsonResponse() {}
|
~AsyncJsonResponse() {}
|
||||||
JsonVariant & getRoot() { return _root; }
|
JsonVariant & getRoot() { return _root; }
|
||||||
bool _sourceValid() { return _isValid; }
|
bool _sourceValid() { return _isValid; }
|
||||||
void setLength() {
|
void setLength() {
|
||||||
|
|
||||||
_contentLength = _root.measureLength();
|
_contentLength = _root.measureLength();
|
||||||
if (_contentLength) { _isValid = true; }
|
if (_contentLength) { _isValid = true; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue