您好,我在解码嵌套的 JSON 数组时遇到问题。我应该创建什么结构?
我想尽可能避免使用 interface{}
,但我真的不知道在这种情况下是否可行。
我要解码的Json:
"[[[{\"aaa\": \"aaa\"}]]]"
和我想用来解码的结构:
type SomeStructNestedNested struct {
Aaa string `json:"aaa"`
}
type SomeStructNested struct {
SomeStructNestedNested []SomeStructNestedNested
}
type SomeStruct struct {
SomeStructNested []SomeStructNested
}
最佳答案
是的,答案只是一片:
type AutoGenerated [][][]struct {
Aaa string `json:"aaa"`
}
感谢您的提问,我发现了这个 tool 中的错误我总是用它来处理 Go 的 Json 操作,它可以为你节省很多无聊的时间,而且最好使用 ticks `` 来表示 json 字符串,如 here
关于arrays - 在 Go/Golang 中解码嵌套的 JSON 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39902502/