Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yyjson_mut_write supported pass char* dest to avoid memory copy #184

Open
gubaojian opened this issue Sep 30, 2024 · 1 comment
Open

yyjson_mut_write supported pass char* dest to avoid memory copy #184

gubaojian opened this issue Sep 30, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@gubaojian
Copy link

gubaojian commented Sep 30, 2024

currently, cann't pass dest buffer :
yyjson_mut_write(doc, 0, &len);

can yyjson_mut_write supported dest buffer
char* dest; // buffer
yyjson_mut_write(doc, 0, &len, dest);

@ibireme ibireme added the enhancement New feature or request label Sep 30, 2024
@ibireme
Copy link
Owner

ibireme commented Sep 30, 2024

You're right, this is a missing feature. It shouldn't be too hard to add.

One thing to note: the required buffer size may be larger than the final JSON length. For example, serializing "abc" needs 5 bytes (3 + 2), but the JSON writer would need to reserve 20 bytes (3 * 6 + 2) of space.

I'll get this implemented soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants