title: Parsing a JSON into a Map in rust
body: <p>I'm quite a beginner in Rust, and just have encountered a problem with parsing JSON files. I tried using serde_json for the task. I know how to parse an ASCII file as a string, and how to parse its content as a <code>Value</code>, but I need a <code>Map&lt;String, Value&gt;</code> to iterate over the KVPs. I did not get too far, as I stumbled into a reference error. The method I tried is the following:</p>
  
  <pre class="lang-rust prettyprint-override"><code>use std::fs;
  use std::error::Error;
  use serde_json::{Value, Map};
  
  pub struct ConfigSerde;
  
  impl ConfigSerde {
      pub fn read_config(path: &amp;str) -&gt; Result&lt;Map&lt;String, Value&gt;, Box&lt;Error&gt;&gt; {
          let config = fs::read_to_string(path)?;
          let parsed: Value = serde_json::from_str(&amp;config)?;
          let obj: Map&lt;String, Value&gt; = parsed.as_object().unwrap();
          Ok(obj)
      }
  }
  </code></pre>
  
  <p>Once I tried to run this code, the compiler threw the following error:</p>
  
  <pre><code>error[E0308]: mismatched types
    --&gt; src/config/serde.rs:11:39
     |
  11 |         let obj: Map&lt;String, Value&gt; = parsed.as_object().unwrap();
     |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `serde_json::map::Map`, found reference
     |
     = note: expected type `serde_json::map::Map&lt;std::string::String, serde_json::value::Value&gt;`
                found type `&amp;serde_json::map::Map&lt;std::string::String, serde_json::value::Value&gt;`
  </code></pre>
  
  <p>How can I parse a JSON to a <code>Map</code> in rust? I'm open to using alternative crates, although serde_json is the preferred one, as it seems the most robust of all.</p>