如何在Go中反序列化此JSON?
{
"using": [ "jmap-core", "jmap-mail" ],
"methodCalls": [
["method1", {"arg1": "arg1data", "arg2": "arg2data"}, "#1"],
["method2", {"arg1": "arg1data"}, "#2"],
["method3", {}, "#3"]
]
}
我还没弄明白如何正确地让json模块将methodCalls解析为一个类型。我的第一个想法是
type MethodCall struct {
Name string
Params map[string]string
ClientId string
}
然后将其用作列表类型:
type Request struct {
Using []string
MethodCalls []MethodCall
}
但这不起作用。 :使用“正确解析,但”methocCalls“不是。有没有办法让Go将这个JSON解析为我的类型?