
Go
- 1 ответ
- 0 вопросов
0
Вклад в тег
type Two struct {
Two1 string `json:"two_1"`
Two2 string `json:"two_2"`
}
type One struct {
One1 string `json:"one_1"`
One2 string `json:"one_2"`
}
type list struct {
One `json:"one"`
Two `json:"two"`
}
data := `[{"one" : { "one_1": "j_1", "one_2": "j_2" }, "two" : { "two_1": "r_1", "two_2": "r_1"}}, {"one" : { "one_1": "j_1", "one_2": "j_2" }, "two" : { "two_1": "r_1", "two_2": "r_1"}}]`
var lists []list
if err := json.Unmarshal([]byte(data), &lists); err != nil {
println(err.Error())
}
for _, v := range lists {
fmt.Printf("%+v", v.One1)
fmt.Printf("%+v", v.Two2)
}