Go
- 2 ответа
- 0 вопросов
1
Вклад в тег
package main
import (
"encoding/json"
"fmt"
"log"
)
type item struct {
Branche branche `json:"branche"`
}
type branche struct {
BranchCount int `json:"branch_count"`
ID string `json:"id"`
}
func main() {
jsonString := `[
{
"branche": {
"branch_count": 5,
"id": "4504137598462702"
}
},
{
"branche": {
"branch_count": 6,
"id": "450413723846223"
}
}
]`
var items []item
if err := json.Unmarshal([]byte(jsonString), &items); err != nil {
log.Fatalln(err)
}
for _, item := range items {
fmt.Println(item.Branche.BranchCount, item.Branche.ID)
}
}