我想json.Unmarshal
在Go中使用解析此json 。
{
"quotes": [
{
"high": "1.9981",
"open": "1.9981",
"bid": "1.9981",
"currencyPairCode": "GBPNZD",
"ask": "2.0043",
"low": "1.9981"
},
{
"high": "81.79",
"open": "81.79",
"bid": "81.79",
"currencyPairCode": "CADJPY",
"ask": "82.03",
"low": "81.79"
}
]
}
源返回{[]}
有关解析结果的信息。
type GaitameOnlineResponse struct {
quotes []Quote
}
type Quote struct {
high string
open string
bid string
currencyPairCode string
ask string
low string
}
func sampleParse() {
path := os.Getenv("PWD")
bytes, err := ioutil.ReadFile(path + "/rate.json")
if err != nil {
log.Fatal(err)
}
var r GaitameOnlineResponse
if err := json.Unmarshal(bytes, &r); err != nil {
log.Fatal(err)
}
fmt.Println(r)
// {[]}
}
我不知道结果的原因。
我不得不出口。
type GaitameOnlineResponse struct {
Quotes []Quote
}
type Quote struct {
High string
Open string
Bid string
CurrencyPairCode string
Ask string
Low string
}
我解决了
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句