You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parsing the output into struct created automagically from the sample json ( as follows )
JSON:
{"labelAnnotations":[{"description":"anime","mid":"/m/0jxy","score":0.81207085,"topicality":0.81207085},{"description":"art","mid":"/m/0jjw","score":0.59014136,"topicality":0.59014136},{"description":"action figure","mid":"/m/017h86","score":0.5556467,"topicality":0.5556467},{"description":"graphics","mid":"/m/021sdg","score":0.53742254,"topicality":0.53742254},{"description":"video game software","mid":"/m/0987_ns","score":0.52508384,"topicality":0.52508384},{"description":"fiction","mid":"/m/02xlf","score":0.51081264,"topicality":0.51081264},{"description":"screenshot","mid":"/m/01zbnw","score":0.50924677,"topicality":0.50924677},{"description":"recreation","mid":"/m/06bm2","score":0.50229543,"topicality":0.50229543}],"safeSearchAnnotation":{"adult":"VERY_UNLIKELY","medical":"VERY_UNLIKELY","racy":"POSSIBLE","spoof":"VERY_UNLIKELY","violence":"UNLIKELY"}}
Output JSON is always inside of an array. You need to parse like the below;
// The AutoGenerated is defined by you from comment.
type AutoGenerated struct {
LabelAnnotations []struct {
// ...
} `json:"labelAnnotations"`
safeSearchAnnotation struct {
// ...
} `json:"safeSearchAnnotation"`
}
// You need to redefine like this for json.Unmarshal
type Parsable []AutoGenerated
Parts of code responsible for image analysis:
Getting annotations for both labels and safe search at the same time.
Parsing the output into struct created automagically from the sample json ( as follows )
JSON:
STRUCT:
Unfortunately:
GoogleVision.SafeSearchAnnotation.Adult
contains correct valuebut
is always empty.
Any ideas what's missing?
The text was updated successfully, but these errors were encountered: