title: Implementing json marshaller over embedded stuct in Go
body: <p>I have a struct that I would like to efficiently JSON encode:</p>
  
  <pre><code>type MyStruct struct {
      *Meta
      Contents []interface{}
  }
  
  type Meta struct {
      Id int
  }
  </code></pre>
  
  <p>The struct contains meta data of a known form and Contents of an unknown form, The contents list is populated during runtime, so I don't really have control over them. To improve Go's marshalling speed, I would like to implement the Marshaller interface over the Meta struct. The Marshaller interface looks like this:</p>
  
  <pre><code>type Marshaler interface {
          MarshalJSON() ([]byte, error)
  }
  </code></pre>
  
  <p>Please keep in mind that the Meta struct is not as simple as shown here. I've tried implementing the Marshaler interface over the Meta struct, but it seems that when I then JSON marshal MyStruct, the result is only the result returned by the Meta marshalling interface.</p>
  
  <p>So my question is: How can I JSON marshal a struct, that contains en embedded struct with its own JSON marshaller and another struct without one?</p>