Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created October 13, 2014 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slawosz/a07ffe79c852fe1a12a6 to your computer and use it in GitHub Desktop.
Save slawosz/a07ffe79c852fe1a12a6 to your computer and use it in GitHub Desktop.
some go
package main
import "fmt"
import "encoding/json"
type Foo struct {
Foo string
Body interface{}
}
var jsonBody = `
{
"Foo": "bar",
"Body": {
"header": "value"
}
}
`
func main() {
foo := &Foo{}
err := json.Unmarshal([]byte(jsonBody), foo)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(foo)
bar, err := json.Marshal(foo.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(bar))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment