AsyncJson: add option to init with root as json array

ref: https://github.com/bblanchon/ArduinoJson/issues/272
This commit is contained in:
Me No Dev 2016-05-02 19:54:37 +03:00
parent 59732a09bd
commit d74a84455f
1 changed files with 17 additions and 15 deletions

View File

@ -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";
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; }
}