diff --git a/common/include/villas/buffer.hpp b/common/include/villas/buffer.hpp index ff7b1e4c6..7792cf8f3 100644 --- a/common/include/villas/buffer.hpp +++ b/common/include/villas/buffer.hpp @@ -48,7 +48,7 @@ public: int parseJson(json_t **j); - int appendJson(json_t *j); + int appendJson(json_t *j, int flags = JSON_INDENT(4)); }; } /* namespace villas */ diff --git a/common/include/villas/json_buffer.hpp b/common/include/villas/json_buffer.hpp index 484c6cf91..260afab14 100644 --- a/common/include/villas/json_buffer.hpp +++ b/common/include/villas/json_buffer.hpp @@ -39,7 +39,7 @@ protected: public: /** Encode JSON document /p j and append it to the buffer */ - int encode(json_t *j); + int encode(json_t *j, int flags = JSON_INDENT(4)); /** Decode JSON document from the beginning of the buffer */ json_t * decode(); diff --git a/common/lib/buffer.cpp b/common/lib/buffer.cpp index f2d5c6a07..8fbd39622 100644 --- a/common/lib/buffer.cpp +++ b/common/lib/buffer.cpp @@ -75,11 +75,11 @@ int Buffer::parseJson(json_t **j) return 0; } -int Buffer::appendJson(json_t *j) +int Buffer::appendJson(json_t *j, int flags) { size_t l; -retry: l = json_dumpb(j, buf + len, size - len, 0); +retry: l = json_dumpb(j, buf + len, size - len, flags); if (size < len + l) { buf = (char *) realloc(buf, len + l); if (!buf) diff --git a/common/lib/json_buffer.cpp b/common/lib/json_buffer.cpp index 83939c6e7..e3f521955 100644 --- a/common/lib/json_buffer.cpp +++ b/common/lib/json_buffer.cpp @@ -40,9 +40,9 @@ json_t * JsonBuffer::decode() return j; } -int JsonBuffer::encode(json_t *j) +int JsonBuffer::encode(json_t *j, int flags) { - return json_dump_callback(j, callback, this, 0); + return json_dump_callback(j, callback, this, flags); } int JsonBuffer::callback(const char *data, size_t len, void *ctx)