title: JSON.stringify equivalent in Golang for map[string]interface{}
body: <p>I'm new to Golang. I have to stringify a <code>map[string]interface{}</code> in Golang as you would do a <code>JSON.stringify</code> in javascript. In javascript keys which has their values <code>undefined</code> gets omitted when you do <code>JSON.stringify</code> and I want the same thing when I do <code>json.Marshal</code> in Golang for <code>nil</code> values. For e.g. in javascript</p>
  <pre><code>var activity = {&quot;isvalid&quot;: true, &quot;value&quot;: {&quot;prop&quot;: undefined}, &quot;prop&quot;: undefined}
  console.log(JSON.stringify(activity)) 
  // Output: {&quot;isvalid&quot;:true,&quot;value&quot;:{}}
  </code></pre>
  <p>But in Golang if I do this</p>
  <pre><code>activity := map[string]interface{}{
      &quot;isvalid&quot;: true, 
      &quot;value&quot;: map[string]interface{}{&quot;prop&quot;: nil},
      &quot;prop&quot;: nil,
  }
  jsonStr, _ := json.Marshal(activity)
  fmt.Println(string(jsonStr)) 
  // output: {&quot;isvalid&quot;:true,&quot;prop&quot;:null,&quot;value&quot;:{&quot;prop&quot;:null}}
  </code></pre>
  <p><a href="https://play.golang.org/p/dvmz32phdNU" rel="nofollow noreferrer">https://play.golang.org/p/dvmz32phdNU</a></p>
  <p>There is a difference in output, what is a good way to make the output same in Golang as of Javascript?</p>
  <p><strong>EDIT:</strong></p>
  <p>The use case involves getting data from various sources which are of type <code>map[string]interface{}</code> and keys can be arbitrary, so converting it into a struct is not an option for me.</p>