existing_entry = (opts & JSON_C_OBJECT_ADD_KEY_IS_NEW) ? NULL :
lh_table_lookup_entry_w_hash(jso->o.c_object,
(const void *)key, hash);
+
+ // The caller must avoid creating loops in the object tree, but do a
+ // quick check anyway to make sure we're not creating a trivial loop.
+ if (jso == val)
+ return -1;
+
if (!existing_entry)
{
const void *const k = (opts & JSON_C_OBJECT_KEY_IS_CONSTANT) ?
printf("my_array.to_string()=%s\n", json_object_to_json_string(my_array));
my_object = json_object_new_object();
+ int rc = json_object_object_add(my_object, "abc", my_object);
+ if (rc != -1)
+ {
+ printf("ERROR: able to successfully add object to itself!\n");
+ fflush(stdout);
+ }
json_object_object_add(my_object, "abc", json_object_new_int(12));
json_object_object_add(my_object, "foo", json_object_new_string("bar"));
json_object_object_add(my_object, "bool0", json_object_new_boolean(0));