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