Open
Description
I am trying to parse a json file (using json.h) and then serialize a sub object of it using json-builder, but I get some strange results.
In this simple example, my input data is:
{ "data": {"x": 10}}
And I try to serialize {"x": 10}
, but instead I get:
{ "x": 10 }{ "data": { "x": 10 } }
Here is the code, compiled on linux with gcc:
#include "json-builder.h"
#include <string.h>
#include <stdio.h>
static const char *JSON = "{\"data\": {\"x\":10}}";
int main()
{
char err[128];
char *buf;
json_value *value, *data;
json_settings settings = {};
settings.value_extra = json_builder_extra;
value = json_parse_ex(&settings, JSON, strlen(JSON), err);
data = value->u.object.values[0].value;
buf = malloc(json_measure(data));
json_serialize(buf, data);
printf("%s\n", buf);
free(buf);
json_builder_free(value);
}
Metadata
Metadata
Assignees
Labels
No labels