私は、構造体golangのjsonからキーと値にアクセスするには?
type Order struct {
ID string `json:"id"`
CustomerMobile string `json:"customerMobile"`
CustomerName string `json:"customerName"`
}
とJSONデータを持っている:
[{"Key":"S001", "Record":{"id":"SOO1","customerMobile":"12344566","customerName":"John"}}]
は、どのように私は上記のJSONオブジェクトからcustomerMobileキーにアクセスすることができますか?
私はGoogleでいくつかの調査を行いましたが、私は以下の解決策を見つけましたが、上記の要件に当てはまる場合は機能しません。シンプルなjson形式で動作します。
jsonByteArray := []byte(jsondata)
json.Unmarshal(jsonByteArray, &order)
customerMobileキーの値にアクセスする方法 –
@helloworld 'things [0] .Record.CustomerMobile'はあなたにキーを与えます。詳細 - https://play.golang.org/p/kBX6jqdSA- –