2 回答

TA貢獻1777條經驗 獲得超10個贊
您的App結構甚至與您嘗試解組的 json 文檔沒有密切相關。要解組 json 文檔,您必須有一個與底層文檔的結構有些匹配的 Go 結構。
type ResponseValue struct {
StartTime int64 `json:"startTimeMillis"`
// other elements of Values here, if you're interested in them
}
type Response struct {
Id int `json:"Id"`
Name string `json:"Name"`
Path string `json:"Path"`
Frequency string `json:"frequency"`
Values []ResponseValue `json:"Values"`
}
type Body struct {
Response []Response `json:"response"`
}
var data Body
json.Unmarshal([]byte(ame.Response),&data)
然后,您可以從 中提取時間序列data。

TA貢獻1811條經驗 獲得超6個贊
這是你的響應結構
type Response struct {
? ? ID? ? ? ? int? ? `json:"Id"`
? ? Name? ? ? string `json:"Name"`
? ? Path? ? ? string `json:"Path"`
? ? Frequency string `json:"frequency"`
? ? Values? ? []struct {
? ? ? ? StartTimeInMillis int64 `json:"startTimeInMillis"`
? ? ? ? Occurrences? ? ? ?int? ?`json:"occurrences"`
? ? ? ? Current? ? ? ? ? ?int? ?`json:"current"`
? ? ? ? Min? ? ? ? ? ? ? ?int? ?`json:"min"`
? ? ? ? Max? ? ? ? ? ? ? ?int? ?`json:"max"`
? ? ? ? UseRange? ? ? ? ? bool? `json:"useRange"`
? ? ? ? Count? ? ? ? ? ? ?int? ?`json:"count"`
? ? ? ? Sum? ? ? ? ? ? ? ?int? ?`json:"sum"`
? ? ? ? Value? ? ? ? ? ? ?int? ?`json:"value"`
? ? ? ? StandardDeviation int? ?`json:"standardDeviation"`
? ? } `json:"Values"`
}
- 2 回答
- 0 關注
- 200 瀏覽
添加回答
舉報