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;
|
||||
bool _isValid;
|
||||
public:
|
||||
AsyncJsonResponse(): _isValid{false} {
|
||||
AsyncJsonResponse(bool isArray): _isValid{false} {
|
||||
_code = 200;
|
||||
_contentType = "text/json";
|
||||
_root = _jsonBuffer.createObject();
|
||||
if(isArray)
|
||||
_root = _jsonBuffer.createArray();
|
||||
else
|
||||
_root = _jsonBuffer.createObject();
|
||||
}
|
||||
~AsyncJsonResponse() {}
|
||||
JsonVariant & getRoot() { return _root; }
|
||||
bool _sourceValid() { return _isValid; }
|
||||
void setLength() {
|
||||
|
||||
_contentLength = _root.measureLength();
|
||||
if (_contentLength) { _isValid = true; }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue