title: What's the best way to maintain un-parsed JSON fields in Go?
body: <p>I'd like to decode a JSON blob into a Go struct, manipulate on it, and encode it back to JSON.  However, there are dynamic fields in the JSON that aren't relevant to my struct and I want to maintain them when I serialize back to JSON.</p>
  
  <p>For example:</p>
  
  <pre><code>{ "name": "Joe Smith", 
    "age": 42, 
    "phone": "614-555-1212", 
    "debug": True, 
    "codeword": "wolf" }
  
  type Person struct {
      Name string
      Age uint
      Phone string
  }
  
  var p Person
  json.Unmarshal(data, &amp;p)
  // Happy birthday
  p.Age++
  data, _ = json.Marshal(p)
  
  // Any way to maintain the "debug" and "codeword" fields -- which might not
  // be known ahead of time?
  </code></pre>
  
  <p>I know one possibility is to decode everything into a <code>map[string]interface{}</code> but boy, do things get ugly when you do that.</p>
  
  <p>Is there any way to have the best of both worlds?</p>