Skip to content

Instantly share code, notes, and snippets.

@mrcampbell
Created November 13, 2020 05:56
Show Gist options
  • Save mrcampbell/8f33d96951ee757a7f8123355aeaf704 to your computer and use it in GitHub Desktop.
Save mrcampbell/8f33d96951ee757a7f8123355aeaf704 to your computer and use it in GitHub Desktop.
// Decode the request
type TargetObject struct {
ID string `json:"id"`
}
// binaryOfOurSourcePayload = []byte(`{"id": "ABC123"}`)
var targetObject TargetObject
err = json.Unmarshal(binaryOfOurSourcePayload, &targetObject)
if err != nil {
// handle error
}
// now the value of TargetObject is TargetObject{ID: "ABC123"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment