1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

buffer: allow JSON indention

This commit is contained in:
Steffen Vogel 2020-07-27 16:40:19 +02:00
parent cd9ab7625e
commit f38fccc20a
4 changed files with 6 additions and 6 deletions

View file

@ -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 */

View file

@ -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();

View file

@ -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)

View file

@ -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)