January 2019
Intermediate to advanced
520 pages
14h 32m
English
If you want to keep a certain part of your data deserialized but you don't know the structure of the data and you want to explore it later in runtime, you can use the generic serde_json::Value, which represents a value of any type. For example, the serde_json crate includes a Value object and a method to deserialize types from an instance of Value. This may be useful in difficult deserialization cases in which you need to reorder the representation before it's completely deserialized.
To use a generic Value, add it to your struct. Consider the following, for example:
#[derive(Deserialize)]struct Response { id: u32, result: serde_json::Value,}
Here, we used a generic value of the serde_json crate. When you need to deserialize it ...
Read now
Unlock full access