Skip to content

Instantly share code, notes, and snippets.

@noamt
Last active July 10, 2021 13:54
Show Gist options
  • Save noamt/a58cc6510d131b1a3cba0b0339086310 to your computer and use it in GitHub Desktop.
Save noamt/a58cc6510d131b1a3cba0b0339086310 to your computer and use it in GitHub Desktop.
Partial unmarshal for Medium post "Using Go's json.RawMessage"
contents := []byte(`
{
"key": "value",
"key2": "value2",
}
`)
type Custom struct {
Key string
Key2 json.RawMessage
}
customStructure := &Custom{}
_ = json.Unmarshal(contents, customStructure)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment