I'm a newbie to go and trying to write a simple app to pull some school data from greatschools.org. The json data looks like this:
{
"schools": {
"school": [
{
"gsId": 1,
"name": "Catholic School",
"type": "private",
"gradeRange": "PK-9",
"enrollment": 39,
"parentRating": 4,
"city": "Denver",
"state": "CO",
"address": "111 Main St.,
Denver, CO 80100",
"phone": "(720) 555-1212",
"fax": "(720) 555-1212",
"website": "http://www.myschool.org",
"ncesId": "1234567",
"lat": 30.519446,
"lon": -105.71314,
"overviewLink": "http://www.greatschools.org/colorado/Denver/1-Catholic-School/?s_cid=gsapi",
"ratingsLink": "http://www.greatschools.org/school/rating.page?state=CO&id=1&s_cid=gsapi",
"reviewsLink": "http://www.greatschools.org/school/parentReviews.page?state=CO&id=1&s_cid=gsapi",
"schoolStatsLink": "http://www.greatschools.org/cgi-bin/CO/otherprivate/1"
}...
My structs look like this:
type SchoolStruct struct {
GsId int
Name string
SchoolType string
GradeRange string
Enrollment int
ParentRating int
City string
State string
Address string
Phone string
Fax string
Website string
NcesId string
Lat float64
Lon float64
OverviewLink string
RatingsLink string
ReviewsLink string
SchoolStatsLink string
}
type SchoolsStruct struct {
Schools []SchoolStruct
}
When I run my code I get "json: cannot unmarshal object into Go value of type []main.SchoolStruct"
I'm using the gopencils library to make my requests and have used it successfully with very simple requests. Do you see what I might be doing wrong?