json response is more human readable with PrettyAsyncJsonResponse class (#398)
* Update AsyncJson.h Adding PrettyAsyncJsonResponse class * Update AsyncJson.h * Adding a PrettyAsyncJsonResponse class json response is more human readable than with AsyncJsonResponse
This commit is contained in:
parent
d55dd73e44
commit
781bddf20c
|
@ -78,7 +78,7 @@ class ChunkPrint : public Print {
|
|||
};
|
||||
|
||||
class AsyncJsonResponse: public AsyncAbstractResponse {
|
||||
private:
|
||||
protected:
|
||||
|
||||
#ifdef ARDUINOJSON_5_COMPATIBILITY
|
||||
DynamicJsonBuffer _jsonBuffer;
|
||||
|
@ -140,6 +140,21 @@ class AsyncJsonResponse: public AsyncAbstractResponse {
|
|||
}
|
||||
};
|
||||
|
||||
class PrettyAsyncJsonResponse: public AsyncJsonResponse {
|
||||
public:
|
||||
PrettyAsyncJsonResponse (bool isArray=false) : AsyncJsonResponse{isArray} {}
|
||||
size_t setLength () {
|
||||
_contentLength = _root.measurePrettyLength ();
|
||||
if (_contentLength) {_isValid = true;}
|
||||
return _contentLength;
|
||||
}
|
||||
size_t _fillBuffer (uint8_t *data, size_t len) {
|
||||
ChunkPrint dest (data, _sentLength, len);
|
||||
_root.prettyPrintTo (dest);
|
||||
return len;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::function<void(AsyncWebServerRequest *request, JsonVariant &json)> ArJsonRequestHandlerFunction;
|
||||
|
||||
class AsyncCallbackJsonWebHandler: public AsyncWebHandler {
|
||||
|
|
Loading…
Reference in New Issue