in parson.c [1916:1935]
JSON_Status json_object_set_value(JSON_Object *object : itype(_Ptr<JSON_Object>), const char *name : itype(_Nt_array_ptr<const char>), JSON_Value *value : itype(_Ptr<JSON_Value>)) {
size_t i = 0;
_Ptr<JSON_Value> old_value = NULL;
if (object == NULL || name == NULL || value == NULL || value->parent != NULL) {
return JSONFailure;
}
old_value = json_object_get_value(object, name);
if (old_value != NULL) { /* free and overwrite old value */
json_value_free(old_value);
for (i = 0; i < json_object_get_count(object); i++) {
if (strcmp(object->names[i], name) == 0) {
value->parent = json_object_get_wrapping_value(object);
object->values[i] = value;
return JSONSuccess;
}
}
}
/* add new key value pair */
return json_object_add(object, (_Nt_array_ptr<const char>)name, value);
}