如何反序列化混合类型的列表? [重复]

This question already has an answer here:

How would I deserialize this JSON in Go?

{
  "using": [ "jmap-core", "jmap-mail" ],
  "methodCalls": [
    ["method1", {"arg1": "arg1data", "arg2": "arg2data"}, "#1"],
    ["method2", {"arg1": "arg1data"}, "#2"],
    ["method3", {}, "#3"]
  ]
}

I haven't figured out how to properly get the json module to parse the methodCalls into a type. My first idea was

type MethodCall struct {
    Name string
    Params map[string]string
    ClientId string
}

and then to use it as a list type:

type Request struct {
    Using []string
    MethodCalls []MethodCall
}

But this does not work. :using" is correctly parsed, but the "methocCalls" are not. Is there a way to get Go to parse this JSON into my types?

</div>

It looks like the methodCalls that you are trying to deserialize it is an array of strings instead of a struct for MethodCall. So, Take a look at this link that I am deserializing as an array.

If you want to use the MethodCall struct you have to change the json a little bit. Take a look at this link