How do I create a Rust HashMap where the value can be one of multiple types?
<p>I want to make a JSON object which includes multiple types. Here's the structure:</p>

<pre><code>{
    "key1": "value",
    "key2": ["val", "val", "val"]
    "key3": { "keyX": 12 }
}
</code></pre>

<p>How can I make a <code>HashMap</code> which accepts all these types?</p>

<p>I'm trying this:</p>

<pre><code>let item = HashMap::new();
item.insert("key1", someString); //type is &amp;str
item.insert("key2", someVecOfStrings); //type is Vec&lt;String&gt;
item.insert("key3", someOtherHashMap); //Type is HashMap&lt;&amp;str, u32&gt;

let response = json::encode(&amp;item).unwrap();
</code></pre>

<p>I know that the hash map does not have enough type info, but I'm not sure how I can make it work. I have tried setting an explicit type on <code>item</code> which was <code>HashMap&lt;&amp;str, Encodable&gt;</code> but then it's just another error. What is the correct way to do this?</p>