in include/yyjson/yyjson.h [6726:6750]
yyjson_api_inline bool yyjson_mut_obj_put(yyjson_mut_val *obj,
yyjson_mut_val *key,
yyjson_mut_val *val) {
bool replaced = false;
size_t key_len;
yyjson_mut_obj_iter iter;
yyjson_mut_val *cur_key;
if (yyjson_unlikely(!yyjson_mut_is_obj(obj) ||
!yyjson_mut_is_str(key))) return false;
key_len = unsafe_yyjson_get_len(key);
yyjson_mut_obj_iter_init(obj, &iter);
while ((cur_key = yyjson_mut_obj_iter_next(&iter)) != 0) {
if (unsafe_yyjson_equals_strn(cur_key, key->uni.str, key_len)) {
if (!replaced && val) {
replaced = true;
val->next = cur_key->next->next;
cur_key->next = val;
} else {
yyjson_mut_obj_iter_remove(&iter);
}
}
}
if (!replaced && val) unsafe_yyjson_mut_obj_add(obj, key, val, iter.max);
return true;
}