ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
2.98k stars 262 forks source link

Support `yyjson_mut_obj_add_obj` & `yyjson_mut_obj_add_arr` like `yyjson_mut_arr_add_*` #140

Closed CarterLi closed 10 months ago

CarterLi commented 10 months ago

Is your feature request related to a problem? Please describe.

We do have yyjson_mut_arr_add_obj and yyjson_mut_arr_add_arr but not yyjson_mut_obj_add_obj and yyjson_mut_obj_add_arr, which seems strange.

Describe the solution you'd like

yyjson_api_inline yyjson_mut_val* yyjson_mut_obj_add_obj(yyjson_mut_doc *doc,
                                                          yyjson_mut_val *obj,
                                                          const char *_key) {
    yyjson_mut_val* newObj = yyjson_mut_obj(doc);
    yyjson_mut_obj_add_val(doc, obj, _key, newObj);
    return newObj;
}

yyjson_api_inline yyjson_mut_val* yyjson_mut_obj_add_arr(yyjson_mut_doc *doc,
                                                          yyjson_mut_val *obj,
                                                          const char *_key) {
    yyjson_mut_val* newArr = yyjson_mut_arr(doc);
    yyjson_mut_obj_add_val(doc, obj, _key, newArr);
    return newArr;
}

Describe alternatives you've considered

I add it manually to my repo, but I think it would be better if yyjson supports it natively

Additional context Add any other context or screenshots about the feature request here.

ibireme commented 10 months ago

Thanks! The two missing functions have been added.

CarterLi commented 10 months ago

What about a new release?

ibireme commented 10 months ago

What about a new release?

It's released every six months and the next one should be in Dec. Since there will be no major feature changes to this library, I want to keep the releases slow.

CarterLi commented 10 months ago

The problem is that fastfetch will release a new version soon, and it uses these two new functions.

I have updated the embed yyjson source in fastfetch source tree. However some package managers prefer system installed yyjson package. These two fns doesn't exist in 0.6.0 so that fastfetch build will fail. Even if I revert the upgrade-yyjson commit in fastfetch, once new version of yyjson is released, fastfetch build will fail because of the duplicated yyjson_mut_arr_add_* functions.

So that new version of fastfetch must be released after new version of yyjson. Any ideas?

ibireme commented 10 months ago

I see, in that case, let's go ahead and release a new version.

ibireme commented 10 months ago

Done: https://github.com/ibireme/yyjson/releases/tag/0.8.0