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

Is there a recommended alternative to serde_value? #2780

Open
kszlim opened this issue Jul 28, 2024 · 4 comments
Open

Is there a recommended alternative to serde_value? #2780

kszlim opened this issue Jul 28, 2024 · 4 comments

Comments

@kszlim
Copy link

kszlim commented Jul 28, 2024

I'm trying to build serde's internal representation directly, and there doesn't seem to be a way to do that via serde, thus far, i've been constructing a proxy for that via using serde_json types directly. But I'm wondering if there's a more efficient way?

serde_value looks like what I need, but it also looks unmaintained, perhaps it's a "done" crate? I'm looking for any recommendations.

@rushmorem
Copy link

I'm currently working on such an alternative. It addresses a lot of the outstanding issues on serde-value.

@kszlim
Copy link
Author

kszlim commented Aug 2, 2024

Cool! I notice that everything is boxed unfortunately, is there any potentially workaround to leave "dense" primitive types unboxed (while preserving nullability)?

@rushmorem
Copy link

Not everything is boxed. Only structs, enums and non-null options. Those are boxed because the type is self-referential in those variants. The internal Serde type is also structured in a similar way.

is there any potentially workaround to leave "dense" primitive types unboxed (while preserving nullability)?

Well, non-optional values are treated as Some(value) if you deserialise them into an Option so you can avoid a heap allocation by serialising primitive types directly instead of wrapping them in Some where possible.

@rushmorem
Copy link

Initial version is now out.

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