亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將 JSON 解組為結構

將 JSON 解組為結構

Go
至尊寶的傳說 2023-02-06 18:55:22
我正在嘗試將以下 JSON 字符串解組到下面的結構中;{   "io.confluent.connect.avro.ConnectDefault":{      "lastModifiedAt":{         "string":"2022-09-01T02:22:19+00:00"      },      "taxRateId":{         "int":5      },      "basedOn":{         "string":"Markup"      },      "priceTax":{         "double":2.04      },      "price":{         "int":24      },      "status":{         "string":"active"      },      "costPrice":{         "int":24      },      "createdAt":{         "string":"2022-09-01T02:22:19+00:00"      },      "productId":{         "int":3545      },      "ownershipId":{         "int":1      },      "dbId":{         "int":3655      },      "markupPercentage":{         "int":0      }   }}type Wrapper struct {    Message `json:"io.confluent.connect.avro.ConnectDefault"`}type Message struct {    DbId Field `json:"dbId"`}type Field struct {    Value map[string]interface{}}但它給了我Field地圖的空值。不確定我在這里做錯了什么。JSON去解組
查看完整描述

1 回答

?
蕭十郎

TA貢獻1815條經驗 獲得超13個贊

這是因為您有額外的嵌套級別:

type Message struct {
    DbId map[string]interface{} `json:"dbId"`}

dbId屬性的值是map任何東西的一個string。


查看完整回答
反對 回復 2023-02-06
  • 1 回答
  • 0 關注
  • 112 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號