alibaba-cloud-sdk-go
alibaba-cloud-sdk-go copied to clipboard
同步帐单出现异常
{"error": "[SDK.JsonUnmarshalError] Failed to unmarshal response, but you can get the data via response.GetHttpStatusCode() and response.GetHttpContentString() caused by: bssopenapi.QueryBillOverviewResponse.Data: bssopenapi.Data.Items: []bssopenapi.Item: decode slice: expect [ or n, but found {, error found in #10 byte of ...|,"Items":{"Item":[{"|..., bigger context ...|"2021-04","AccountID":"xxxxxxx","Items":{"Item":[{"DeductedByCoupons":0.000000,"RoundDownDi|..."}
版本: github.com/aliyun/alibaba-cloud-sdk-go v1.61.1208
type Data struct {
// 这个结构体官方有问题,重新自定义
Items map[string][]billing.Item `json:"Items" xml:"Items"`
}
type QueryBillOverviewResponse struct {
RequestId string `json:"RequestId" xml:"RequestId"`
Success bool `json:"Success" xml:"Success"`
Code string `json:"Code" xml:"Code"`
Message string `json:"Message" xml:"Message"`
Data Data `json:"Data" xml:"Data"`
}
var (
result QueryBillOverviewResponse
)
request := billing.CreateQueryBillOverviewRequest()
request.BillingCycle = billingCycle
request.AcceptFormat = "json"
request.Scheme = "https"
resp, _ := client.billingClt.QueryBillOverview(request)
body := resp.GetHttpContentBytes()
// 这里自解析结构体太深,忽略错误吧
json.Unmarshal(body, &result)
for _, instance := range result.Data.Items["Item"] {
// 正常的遍历就OK
}
坐等官方更新,我看所有的接口都是有问题的JSON格式
v1.61.1352有这个问题 v1.61.1311没有这个问题,可以回滚