[go-nuts] Re: How to convert JSON message to Go struct

2017-10-11 Thread Christian LeMoussel
It's OK.Thank you very much. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.goog

[go-nuts] Re: How to convert JSON message to Go struct

2017-10-11 Thread Tamás Gulácsi
s1, i1, s2, i2 := workpack[0][0].(string), int(workpack[0][1].(float64)), workpack[0][2].(string), int(workpack[0][3].(float64)) 2017. október 11., szerda 9:02:17 UTC+2 időpontban Christian LeMoussel a következőt írta: > > Ok but how can I acces four values? > > I do this > segments = > [

Re: [go-nuts] Re: How to convert JSON message to Go struct

2017-10-11 Thread Gianguido Sorà
You should operate type assertion by iterating on the array. My advice is to write a "Work" struct with all the field you need, and create an instance for each iteration of the outer array. This way you'll have a nice representation of a "Work" package for each inner array. I cannot p

[go-nuts] Re: How to convert JSON message to Go struct

2017-10-11 Thread Christian LeMoussel
Ok but how can I acces four values? I do this segments = []byte("[[\"19c87d4ddf59160406821ca102aa4f49846ecf5ac3d41d2007883834\", 75, \"b54317cb538c6b3a5ae8b84f8b53c83652037038ad8ad6bef4c8b43a\", 101]]") var workPack [][]interface{} err = json.Unmarshal(segments, &workPack) chec

[go-nuts] Re: How to convert JSON message to Go struct

2017-10-10 Thread Dave Cheney
Sadly this is not a JSON object, it's an array containing an array containing four values. The Go defintion created for you by that tool is the best way to express this data in Go. On Wednesday, 11 October 2017 17:40:41 UTC+11, Christian LeMoussel wrote: > > > Hi, I'm new to Go, > > I have diff