title: How to ignore MarshalJSON implementation of a struct (with nested structs)?
body: <p>Is it possible to ignore a custom <code>MarshalJSON</code> implementation of a struct,
  and use just standard marshaling function instead?</p>
  <p>The struct is complex, and has a lot of nested structs, all of which are
  using custom <code>MarshalJSON</code>, and I would like to ignore them all.</p>
  <p>I feel that it should be trivial. Do you have an idea?</p>
  <p><strong>Some details</strong></p>
  <p>An obvious solution with a new type creation does not work well, because the nested structs still use their <code>MarshalJSON</code>s.</p>
  <p>Here is an example of the code:</p>
  <pre><code>func (de DeploymentExtended) MarshalJSON() ([]byte, error) {
      objectMap := make(map[string]interface{})
      if de.Location != nil {
          objectMap[&quot;location&quot;] = de.Location
      }
      if de.Properties != nil {
          objectMap[&quot;properties&quot;] = de.Properties
      }
      if de.Tags != nil {
          objectMap[&quot;tags&quot;] = de.Tags
      }
      return json.Marshal(objectMap)
  }
  </code></pre>
  <p>(source: <a href="https://github.com/Azure/azure-sdk-for-go/blob/v62.0.0/services/resources/mgmt/2020-10-01/resources/models.go#L366" rel="nofollow noreferrer">https://github.com/Azure/azure-sdk-for-go/blob/v62.0.0/services/resources/mgmt/2020-10-01/resources/models.go#L366</a>)</p>
  <p>And there are a lot of properties (like <code>Name</code>, etc), which I would like to see in my JSON (the same for <code>Properties</code> and other nested structs).</p>
  <p>The Python implementation of this code provides that data, my software use it, and I (porting the code to Go) would like to be able to export these data from my Go program too.</p>