I am using libjosn-c
as below and encounter a Segmentation fault error.
If I remove the line json_object_object_add(root, "Child", value);
, no error occurs.
int main(int argc, char **argv)
{
json_object *root = NULL, *value = NULL;
root = json_object_new_string("My Object");
value = json_object_new_string("My Child Object");
json_object_object_add(root, "Child", value);
printf("to string =%s\n", json_object_to_json_string(root));
json_object_put(value);
json_object_put(root);
return 0;
}
I am not experienced in libjson-c
.
Thanks for your help!