How to (de)serialize a strongly typed JSON dictionary in Serde?
问题 I am writing a Rust application that handles JSON messages from a TypeScript client with a public interface. I have written some code using serde_derive and it works well, but I can't figure out how to implement dictionaries; e.g.: { "foo" : { "data" : 42 }, "bar" : { "data" : 1337 } } Here the keys are the strings "foo" and "bar" and the dictionary's values follow this schema: use serde_derive; use serde_json::Number; #[derive(Serialize, Deserialize)] struct DictionaryValue { data: Number, }