title: When to use a pointer to a nested struct for JSON?
body: <p><code>EDIT</code>: I feel this question is not a duplicate, as the referenced Q&amp;A do not describe JSON in the use cases.</p>
  
  <p>I have a <code>struct</code> nested within another <code>struct</code> that I use for JSON operations.</p>
  
  <p>In a simple test case, <a href="https://play.golang.org/p/YUWnA7Lpy1Z" rel="nofollow noreferrer">using a copy</a> of a nested struct:</p>
  
  <pre><code>type A struct {
      Foo string
      Bar B
  }
  
  type B struct {
      Baz string
  }
  
  func main() {
      serialized := `{"foo": "some", "bar": {"baz": "thing"}}`
      a := &amp;A{}
      json.Unmarshal([]byte(serialized), a)
      fmt.Println(a.Foo, a.Bar.Baz)
  }
  &gt; some thing
  </code></pre>
  
  <p>yields the same results as <a href="https://play.golang.org/p/Q38ANGvjIvx" rel="nofollow noreferrer">using a pointer</a> to a nested struct:</p>
  
  <pre><code>type A struct {
      Foo string
      Bar *B
  }
  
  type B struct {
      Baz string
  }
  
  func main() {
      serialized := `{"foo": "some", "bar": {"baz": "thing"}}`
      a := &amp;A{}
      json.Unmarshal([]byte(serialized), a)
      fmt.Println(a.Foo, a.Bar.Baz)
  }
  &gt; some thing
  </code></pre>
  
  <p>When would or would I not want to use a pointer?</p>