Actually, at the entrance - JSON of the following form:
{ "classifiers" : [ { "classifier_id" : "9a9388x45-nlc-1361", "url" : "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/9a9388x45-nlc-1361", "name" : "data", "language" : "en", "created" : "2016-03-27T03:46:13.965Z" }, { "classifier_id" : "9a9388x45-nlc-1363", "url" : "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/9a9388x45-nlc-1363", "name" : "data", "language" : "en", "created" : "2016-03-27T03:51:12.911Z" }, ... ] }
I am trying to present the following structures:
type WatsonClassifier struct { ClassifierID string `json:"classifier_id"` Language string `json:"language"` url string username string password string } type WatsonClassifierList struct { Classifiers []Classifier `json:"classifiers"` }
But as a result:
classifierList := WatsonClassifierList{} json.Unmarshal(answer, &classifierList) fmt.Println(classifierList)
I have this exhaust:
{[<nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil>]}
Those. instead of classifiers - nil. What am I doing wrong?
fmt.Println(string(answer))
). And yes - if the problem were this, then where did it get the correct number nil-in (8 elements, as it should be). - Alexander Pozharskii