I just started developing in Golang, and am up against this problem:
I have json data to be accepted by a Golang server. A sample of one of the fields of this json data is below:
"DATA":[["(610, 658)",1573824148],["(594, 675)",1573824148],["(578,710)",1573824148],["(571, 728)",1573824148],["(552, 769)",1573824148],["(549, 788)",1573824148],["(549, 796)",1573824148]]
Note that it is an array of lists, each list being a string and an integer.
I have the following data structures declared:
type POINT struct {
p string
t int
}
type POINTS struct {
A int
B int
C string
DATA []FIDGET
}
The relevant field is POINTS.DATA which is an array of POINTs. A POINT is a string and an int. To convert from json to Go variables, I use the encoding/json package.
My problem is, when I call
err = json.Unmarshal(body, &m)
I get this error:
json: cannot unmarshal array into Go struct field POINTS.DATA of type main.POINT
Can anyone help me? Thank you in advance!
FIDGET, or for theFIDGETSshow in the error message.