I want to unmarshal a JSON object where one field contains a JSON string into one coherent object. How do I do that in Go?
Example:
Input:
{"foo":1,"bar":"{\\"a\\":\\"Hello\\"}"}
Go type:
type Child struct { A string `json:"a"`}type Main struct { Foo int `json:"foo"` Bar Child `json:"bar"`}
I guess I'd need to implement a custom UnmarshalJSON
implementation on one of the types, but its twisting my head to figure out on which one and how.