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

Recover raw values after losing the type #1148

Closed
wants to merge 1 commit into from

Conversation

IvanUkhov
Copy link

@IvanUkhov IvanUkhov commented Jun 30, 2024

Hello,

I have a use case where a struct with a raw value gets converted into a Value, which then needs to be serialized to JSON. Upon conversion, RawValue gets downcast to a Map, which loses the special serialization of RawValue, resulting in a JSON containing an object with one entry whose key equals raw::TOKEN.

I am wondering if you would be willing to have code for recovering the “rawness.”

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 for the PR.

Could you give more detail about what your use case is doing to end up with a Value like this? serde_json::to_value should not be producing such a value, for example.

It would be better if the unit test could be more representative of that use case.

@IvanUkhov
Copy link
Author

IvanUkhov commented Jul 1, 2024

It was a good question that made me think a little bit harder. After going back and forth, I have decided to propose a similar change to async-graphql instead, which was the use case I mentioned:

async-graphql/async-graphql#1554

@IvanUkhov IvanUkhov closed this Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants