-
-
Save christian-korneck/be8e34dd639ba5740fcc1eeca138c9d5 to your computer and use it in GitHub Desktop.
Partial unmarshal for Medium post "Using Go's json.RawMessage"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contents := []byte(` | |
{ | |
"key": "value", | |
"key2": "value2" | |
} | |
`) | |
type Custom struct { | |
Key string | |
Key2 json.RawMessage | |
} | |
customStructure := &Custom{} | |
err := json.Unmarshal(contents, customStructure) | |
if err != nil { | |
fmt.Println(err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment