1 --- a/src/util/json.c 2011-03-24 03:10:26.000000000 -0400
2 +++ b/src/util/json.c 2011-04-25 20:01:29.354939116 -0400
5 static int virJSONParserHandleNumber(void * ctx,
10 virJSONParserPtr parser = ctx;
11 char *str = strndup(s, l);
14 static int virJSONParserHandleString(void * ctx,
15 const unsigned char * stringVal,
16 - unsigned int stringLen)
19 virJSONParserPtr parser = ctx;
20 virJSONValuePtr value = virJSONValueNewStringLen((const char *)stringVal,
23 static int virJSONParserHandleMapKey(void * ctx,
24 const unsigned char * stringVal,
25 - unsigned int stringLen)
28 virJSONParserPtr parser = ctx;
29 virJSONParserStatePtr state;
31 /* XXX add an incremental streaming parser - yajl trivially supports it */
32 virJSONValuePtr virJSONValueFromString(const char *jsonstring)
34 - yajl_parser_config cfg = { 1, 1 };
36 virJSONParser parser = { NULL, NULL, 0 };
37 virJSONValuePtr ret = NULL;
39 VIR_DEBUG("string=%s", jsonstring);
41 - hand = yajl_alloc(&parserCallbacks, &cfg, NULL, &parser);
42 + hand = yajl_alloc(&parserCallbacks, NULL, &parser);
43 + yajl_config(hand, yajl_allow_comments, 1);
46 (const unsigned char *)jsonstring,
47 @@ -1002,15 +1002,16 @@
49 char *virJSONValueToString(virJSONValuePtr object)
51 - yajl_gen_config conf = { 0, " " }; /* Turns off pretty printing since QEMU can't cope */
53 const unsigned char *str;
58 VIR_DEBUG("object=%p", object);
60 - g = yajl_gen_alloc(&conf, NULL);
61 + g = yajl_gen_alloc(NULL);
62 + yajl_gen_config(g, yajl_gen_beautify, 0);
63 + yajl_gen_config(g, yajl_gen_indent_string, " ");
65 if (virJSONValueToStringOne(object, g) < 0) {