Skip to content

Conversation

@bheylin
Copy link
Contributor

@bheylin bheylin commented Dec 11, 2024

I have been using RawValue a lot lately to implement server endpoints that accept large JSON objects, extract some specific fields and ultimately save the entire JSON to the DB.

As part of this process, a proc-macro based JSON pre-processor is used to automate HTTP error responses. This also uses RawValue to avoid allocating when traversing unknown JSON data.

The pre-processor uses literal "null"'s as part of it's logic, and at the moment I'm deserializing a literal "null" string to RawValue every time I need one.

This could be done once and stored in a LazyLock or something similar, but I thought that adding literal values to the RawValue struct is the least complex solution.

What do you think?

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 96576ba into serde-rs:master Dec 11, 2024
16 checks passed
@dtolnay
Copy link
Member

dtolnay commented Dec 21, 2024

Published in serde_json 1.0.134.

I was waiting to publish this because I was not happy with how rustdoc originally rendered these. rust-lang/rust#134321

@bheylin
Copy link
Contributor Author

bheylin commented Dec 21, 2024

No worries, there's no rush on a release for me.

I didn't realize that Rustdoc rendered each impl literally.

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

Labels

None yet

2 participants