您好,我试图取消marshax字段中数组的值,但尝试返回空数组,我不知道原因。任何人都可以帮我吗?代码如下:
package main
import (
"fmt"
"encoding/json"
)
func main() {
fmt.Println("Hello, playground")
type order struct {
Uid string `json:"uid"`
Name string `json:"name"`
State string `json:"state"`
}
type Root struct {
q []order
}
s := `{"q":[{"uid":"0x4ecb99b9","name":"Brandon Test Order","state":"draft"}]}`
var r Root
ero := json.Unmarshal([]byte(s), &r)
if ero != nil {
fmt.Println("error order")
fmt.Println(ero)
}
fmt.Println("order")
fmt.Println(r.q)
return
}
这是输出结果
Hello, playground
order
[]
烙印99
喵喔喔
相关分类