You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It would be nice if we could have public APIs to initializeyyjson_mut_val stack objects that we could then pass along to yyjson_mut_obj_add / yyjson_mut_arr_append. That's because most of the time, the responses are simple and static enough for this to work.
Describe the solution you'd like
Say for instance I want to build:
{code: 5, params: [1, "error-msg"]};
it would be nice if I could do it with no allocations
yyjson_mut_val root, code_key, code_val, params_key, params_arr, one, msg;
/*
* start of missing API
*/
yyjson_mut_set_obj(&root);
yyjson_mut_set_str(&code_key, "code_key");
yyjson_mut_set_int(&code_val, 5);
yyjson_mut_set_str(¶ms_key, "params");
yyjson_mut_set_arr(¶ms_arr);
yyjson_mut_set_int(&one, 1);
yyjson_mut_set_str(&msg, "error-msg");
/*
* end of missing APIs
*/
// we can already do those
yyjson_mut_obj_add(&root, &code_key, &code_val);
yyjson_mut_obj_add(&root, ¶ms_key, ¶ms);
yyjson_mut_arr_append(¶ms, &one);
yyjson_mut_arr_append(¶ms, &msg);
char buf[100];
// ....
yyjson_mut_val_write_opts(&root, &alc ....);
Describe alternatives you've considered
I guess tags could be set manually on the struct instances, but tags are advertised as being part of the private API.
The text was updated successfully, but these errors were encountered:
andrei-datcu
changed the title
mut_doc less public API
Public API to allow building values without allocation (no mut_doc APIs)
Aug 6, 2022
Is your feature request related to a problem? Please describe.
It would be nice if we could have public APIs to initialize
yyjson_mut_val
stack objects that we could then pass along toyyjson_mut_obj_add
/yyjson_mut_arr_append
. That's because most of the time, the responses are simple and static enough for this to work.Describe the solution you'd like
Say for instance I want to build:
it would be nice if I could do it with no allocations
Describe alternatives you've considered
I guess tags could be set manually on the struct instances, but tags are advertised as being part of the private API.
The text was updated successfully, but these errors were encountered: