Closed DennisDNguy closed 1 year ago
Hi I tried this by following code and get no error...
#include <jansson.h>
int main(){
const char *key;
json_t *inobj, *outobj, *value;
// load json from file
FILE *infile, *outfile;
infile = fopen("/home/jansson-test/load.json", "r");
json_error_t error;
inobj = json_loadf(infile, JSON_INDENT(4), &error);
// parse
outobj = json_object();
json_object_foreach(inobj, key, value) json_object_set(outobj, key, value);
// dump result
outfile = fopen("/home/jansson-test/jansson.json", "w+");
json_dumpf(outobj, outfile, JSON_INDENT(4));
fclose(infile);
fclose(outfile);
json_decref(inobj);
json_decref(outobj);
return 0;
}
Thanks @ayin1551 Probably the new v2.14 version fixed the issue.
I have noticed that the json_object_foreach(obj, key, value) function could not detect sub-objects if the sub-objects were at the middle of the objects. For example: