title: Marshal of json.RawMessage
body: <p>Please find the code here <a href="http://play.golang.org/p/zdQ14ItNBZ" rel="nofollow noreferrer">http://play.golang.org/p/zdQ14ItNBZ</a></p>
  
  <p>I am keeping JSON data as RawMessage, but cannot decode it out. I need the containing struct to be Marshalled and Unmarshalled, but I would expect still be able to get the JSON field.</p>
  
  <h2>code:</h2>
  
  <pre><code>package main
  
  import (
      "encoding/json"
      "fmt"
  )
  
  type Data struct {
      Name string
      Id   int
      Json json.RawMessage
  }
  type Data2 struct {
      Name string
      Id   int
  }
  
  
  func main() {
  
      tmp := Data2{"World", 2}
  
      b, err := json.Marshal(tmp)
      if err != nil {
          fmt.Println("Error %s", err.Error())
      }
      fmt.Println("b %s", string(b))
  
      test := Data{"Hello", 1, b}
      b2, err := json.Marshal(test)
      if err != nil {
          fmt.Println("Error %s", err.Error())
      }
  
      fmt.Println("b2 %s", string(b2))
  
      var d Data
      err = json.Unmarshal(b2, &amp;d)
      if err != nil {
          fmt.Println("Error %s", err.Error())
      }
      fmt.Println("d.Json %s", string(d.Json))
  
      var tmp2 Data2
      err = json.Unmarshal(d.Json, &amp;tmp2)
      if err != nil {
          fmt.Println("Error %s", err.Error())
      }
      fmt.Println("Data2 %+v", tmp2)
  
  }
  </code></pre>
  
  <h2>out:</h2>
  
  <pre><code>b %s {"Name":"World","Id":2}
  b2 %s {"Name":"Hello","Id":1,"Json":"eyJOYW1lIjoiV29ybGQiLCJJZCI6Mn0="}
  d.Json %s "eyJOYW1lIjoiV29ybGQiLCJJZCI6Mn0="
  Error %s json: cannot unmarshal string into Go value of type main.Data2
  Data2 %+v { 0}
  </code></pre>