title: Serde JSON from Struct Example Not Working
body: <p>I can't seem to get the provided <a href="https://docs.serde.rs/serde_json/#creating-json-by-serializing-data-structures" rel="nofollow noreferrer">example</a> of serializing a struct with serde to work. I'm implementing the trait <code>Serialize</code> for my <code>Address</code> struct, but I get a compile error that this trait is not implemented. What am I doing wrong?</p>
  <pre><code>[dependencies]
  serde = &quot;1.0.118&quot;
  serde_json = &quot;1.0.60&quot;
  </code></pre>
  <pre class="lang-rust prettyprint-override"><code>use serde::{Deserialize, Serialize};
  use serde_json::Result;
  
  #[derive(Serialize, Deserialize)]
  struct Address {
      street: String,
      city: String,
  }
  fn main(){
      print_an_address();
  }
  
  fn print_an_address() -&gt; Result&lt;()&gt; {
      // Some data structure.
      let address = Address {
          street: &quot;10 Downing Street&quot;.to_owned(),
          city: &quot;London&quot;.to_owned(),
      };
  
      // Serialize it to a JSON string.
      let j = serde_json::to_string(&amp;address)?;
  
      // Print, write to a file, or send to an HTTP server.
      println!(&quot;{}&quot;, j);
  
      Ok(())
  }
  </code></pre>
  <pre><code>error[E0277]: the trait bound `Address: Serialize` is not satisfied
      --&gt; src\main.rs:21:35
       |
  21   |     let j = serde_json::to_string(&amp;address)?;
       |                                   ^^^^^^^^ the trait `Serialize` is not implemented for `Address`
       | 
      ::: C:\Users\Primary User\.cargo\registry\src\github.com-1ecc6299db9ec823\serde_json-1.0.60\src\ser.rs:2221:17
       |
  2221 |     T: ?Sized + Serialize,
       |                 --------- required by this bound in `serde_json::to_string`
  
  </code></pre>