int `json:"y"` } type Line struct { P1 Point `json:"p1"` P2 Point `json:"p2"` } func main() { const input = `{"p1":{"x":10,"y":20},"p2":{"x":30,"y":40}}` var line Line json.NewDecoder(strings.NewReader(input)).Decode(&line) fmt.Println(line.P2.Y) //=> 40 }
end class Line JSON.mapping({ p1: Point, p2: Point, }) end input = %({"p1":{"x":10,"y":20},"p2":{"x":30,"y":40}}) line = Line.from_json(input) puts line.p2.y #=> 40