package main
import (
"encoding/json"
"fmt"
)
var the_json = `
[{"description":"","is_official":false,"is_trusted":true,"name":"foobar/blah","star_count":1}
,{"description":"","is_official":false,"is_trusted":true,"name":"yucks/dog","star_count":0}
,{"description":"","is_official":false,"is_trusted":true,"name":"yonkers/bonkers","star_count":0}
]
`
type Item struct {
description string
is_official bool
is_trusted bool
name string
star_count int
}
func main() {
var items []Item
json.Unmarshal([]byte(the_json), &items)
for _, di := range items {
fmt.Println( "Name: " + di.name + " starred #" + string(di.star_count) + " times" )
}
}
Your fields are not exported, so they won't be written to.
Chris onna bus.
--
Your fields are not exported, so they won't be written to.
Chris, that makes sense. I changed the fields to start with all caps, and that works for the di.Name, but cannot figure out how to get star_count translated. I tried "Star_count", "Star_Count" and "StarCount" without success.