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

Make utf8 serialization (including escaping) public #857

Closed
jorgecarleitao opened this issue Feb 5, 2022 · 2 comments
Closed

Make utf8 serialization (including escaping) public #857

jorgecarleitao opened this issue Feb 5, 2022 · 2 comments

Comments

@jorgecarleitao
Copy link

We had to copy-paste some code from serde_json (jorgecarleitao/arrow2#813). It would be better if serde_json::ser would offer such a functionality in its public API.

Goal: given a &[u8] representing valid utf8, we would like a function that writes it to a writer (e.g. &mut Vec<u8>) taking into account that some bytes will need to be escaped accordingly.

@dtolnay
Copy link
Member

dtolnay commented Feb 5, 2022

I don't fully understand what your crate is doing that it can't just use the existing API of serde_json, but there isn't anything else not already exposed that I would prefer to expose here.

@dtolnay dtolnay closed this as completed Feb 5, 2022
@jorgecarleitao
Copy link
Author

jorgecarleitao commented Feb 5, 2022

I wanted to serialize a &str to json, but that is indeed already supported because &str implements Serialize. I thought that we had to roundtrip over Value, which would require an allocation. Sorry for the noise. :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants