title: Lowercase JSON key names with JSON Marshal in Go
body: <p>I wish to use the <code>"encoding/json"</code> package to marshal a struct declared in one of the imported packages of my application.</p>
  
  <p>Eg.:</p>
  
  <pre><code>type T struct {
      Foo int
  }
  </code></pre>
  
  <p>Because it is imported, all available (exported) fields in the struct begins with an upper case letter. But I wish to have lower case key names:</p>
  
  <pre><code>out, err := json.Marshal(&amp;T{Foo: 42})
  </code></pre>
  
  <p>will result in</p>
  
  <blockquote>
    <p>{"Foo":42}</p>
  </blockquote>
  
  <p>but I wish to get</p>
  
  <blockquote>
    <p>{"foo":42}</p>
  </blockquote>
  
  <p>Is it possible to get around the problem in some easy way?</p>