1 回答

TA貢獻1876條經驗 獲得超7個贊
就問題的理解而言,我的理解是您可以按以下方式格式化數據。
type Payload struct {
? ? OfferName? ?string? ? ? ? ? ? ? ? ?`json:"offer_name"`
? ? OfferID? ? ?string? ? ? ? ? ? ? ? ?`json:"offer_id"`
? ? PartnerName string? ? ? ? ? ? ? ? ?`json:"partner_name"`
? ? PartnerID? ?string? ? ? ? ? ? ? ? ?`json:"partner_id"`
? ? TypeSystem? string? ? ? ? ? ? ? ? ?`json:"type_system"`
? ? Status? ? ? string? ? ? ? ? ? ? ? ?`json:"status"`
? ? DateRequest string? ? ? ? ? ? ? ? ?`json:"date_request"`
? ? BankName? ? string? ? ? ? ? ? ? ? ?`json:"bank_name"`
? ? BankID? ? ? string? ? ? ? ? ? ? ? ?`json:"bank_id"`
? ? TypeProduct string? ? ? ? ? ? ? ? ?`json:"type_product"`
? ? // you can use the type map of array of error data here?
? ? ErrorType? ?map[string][]ErrorData `json:"error_type"`
? ? RequestID? ?string? ? ? ? ? ? ? ? ?`json:"request_id"`
}
type ErrorData struct {
? ? Reason Reason `json:"reason"`
? ? Status string `json:"status"`
? ? SendAt int? ? `json:"send_at"`
}
type Reason struct {
? ? Phone string `json:"phone"`
}
使用以下內容,您可以將數據解組為
fmt.Printf("%+v", p.ErrorType["128"][0].Reason)
如果您不知道地圖的鍵,您仍然可以遍歷地圖值并獲取數據。
- 1 回答
- 0 關注
- 136 瀏覽
添加回答
舉報