-
Notifications
You must be signed in to change notification settings - Fork 553
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
Should TryFrom
be implemented for Value
?
#738
Comments
I think I would prefer not to add those. This use case is already covered by the Deserialize trait in a more flexible way that works for extracting a vector, struct etc as well. let x = u64::deserialize(&value)?; |
Deserializing to a If you're using JSON know the data layout, then serde's Serialization/Deserialization makes a lot of sense to convert to proper Rust structs. But I think people will often have a blob of JSON they will need to work with “dynamically”. The For a |
Given that |
serde_json::Value
has variousas_*
methods which allow conversion to the underlying enum (e.g.as_bool
,as_str
). Rust now has aTryFrom
trait. ShouldTryFrom
be implemented forValue
for things like this? I'm willing to add this myself, but first, I'd like to check it would be accepted, or if there's a good reason it hasn't been implemented yet.The text was updated successfully, but these errors were encountered: