求大神帮忙!C语言,利用 json-C 库处理,json 字符串?
这是要处理的json对象,{\"All\":2, \"Dots\":[{\"C\":1,\"D\":1,\"I\":1,\"T\":0},{\"C\":1,\"D\":1,\"I\":1,\"T\":1}]}我期望得到的结果是:[{"C":1,"D":1,"I":1,"T":0,"V":0.0},{"C":1,"D":1,"I":1,"T":1,"V":2727.0}]
我已经完成了部分工作,代码如下:
new_obj= json_tokener_parse("{\"All\":2,\"Dots\":[{\"C\":1,\"D\":1,\"I\":1,\"T\":0},{\"C\":1,\"D\":1,\"I\":1,\"T\":1}]}");
fprintf(cgiOut,"<h3>my_object.to_string()=%s\n</h3>", json_object_to_json_string(new_obj)); json_object_object_add(new_obj,"V",json_object_new_string("2727.0"));
struct json_object *o = json_object_object_get(new_obj,"Dots");
fprintf(cgiOut,"<h3>my_object.to_string()=%s\n</h3>", json_object_to_json_string(new_obj));
fprintf(cgiOut,"<h3>Dots.to_string()=%s\n</h3>", json_object_to_json_string(o));