title: Generate pretty (indented) JSON with serde
body: <p>Using the <a href="https://github.com/serde-rs/json" rel="noreferrer">serde_json</a> crate, I can use</p>
  
  <pre><code>::serde_json::to_string(&amp;obj)
  </code></pre>
  
  <p>to serialize an object into a JSON string. The resulting JSON uses compact formatting, like:</p>
  
  <pre><code>{"foo":1,"bar":2}
  </code></pre>
  
  <p>But how do I generate pretty/indented JSON? For example, I'd like to get this:</p>
  
  <pre><code>{
    "foo": 1,
    "bar": 2
  }
  </code></pre>