Commit a708c3ab authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

buffer: allow JSON indention

parent 9ea08ef8
......@@ -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 */
......@@ -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();
......
......@@ -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)
......
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment