title: Converting all snake_case keys in a json to camelCase keys
body: <p>In Go, how can we convert snake_case keys in a JSON to camelCase ones recursively?</p>
  <p>I am writing one http api in Go. This api fetches data from datastore, does some computation and returns the response as JSON.</p>
  <p>The situation is that the JSON document in the datastore (ElasticSearch) is present with snake_case keys while the API response should be camelCase-based (this is just to align with other api standards within the project). The source which inserts into ES can't be modified. So it's only at the api level that the key conversion has to take place.</p>
  <p>I have written a struct which is reading JSON from datastore nicely. But how can I convert the keys to camelCase in Go?</p>
  <p>The JSON can be nested and all keys have to be converted.
  The JSON is arbitrarily large; i.e. some keys are just mapped to type interface{}</p>
  <p>I am also using Go's echo framework for writing the api.</p>
  <p>Ex.</p>
  <pre><code>{
  &quot;is_modified&quot; : true,
     { &quot;attribute&quot;: 
       {
        &quot;legacy_id&quot; : 12345 
       }
     }
  }
  </code></pre>
  <p>TO</p>
  <pre><code>{
  &quot;isModified&quot; : true,
     { &quot;attribute&quot;: 
       {
        &quot;legacyId&quot; : 12345 
       }
     }
  }
  </code></pre>
  <p>Any pointers on how to do this in Go?</p>
  <p>Struct:</p>
  <pre><code>type data_in_es struct {
  IsModified bool `json:&quot;is_modified,omitempty&quot;`
  Attribute *attribute `json:&quot;attribute,omitempty&quot;`
  }
  
  type attribute struct {
      LegacyId int `json:&quot;legacy_id,omitempty&quot;`
  }
  </code></pre>