So, I've been tinkering with go and have a small problem. I have something that needs to be serialised into a json like so.
{
"name" : "Steel",
"things" : ["Iron", "Carbon"]
}
The struct to hold this looks like this.
type Message struct {
name string
things []string
}
and my code itself like this
func main() {
i := Message{"Steel", []string{"Iron", "Carbon"}}
fmt.Println(i);
b, _ := json.Marshal(i)
fmt.Printf(" Json %v
", b);
var o Message;
json.Unmarshal(b, &o)
fmt.Printf(" Decoded %v
", o);
}
When I deserialise the data though, I get back an empty Message
like so
{Steel [Iron Carbon]}
Json [123 125]
Decoded { []}
What am I doing wrong and how do I get it to work?