serde-rs/json

Implement `Deserializer` for `Map<String, Value>` and `&Map<String, Value>`

swlynch99 opened this issue · 0 comments

Sometimes I want to work with a Value that I know to be a json object. Map<String, Value> is the correct type to use for this but it is not possible to deserialize from a Map<String, Value> to a more concrete without going through Value. It would be nice if Map<String, Value> implemented Deserializer so this all just works.

My actual use case is that I have a &Map<String, Value> that I would like to deserialize to a concrete struct, which is harder to come up with a workaround for. With an owned value I could just do T::deserialize(Value::Object(map)) but that doesn't work for a reference.