我如何解组这样的东西:
[
2,
"19223201",
"SomeString",
{
"SomeField": "FieldValue",
"SomeField2": "FieldValue2", "SomeFieldN": "FieldValueN", }
]
答案 0 :(得分:0)
如果您没有定义任何接口并在接口类型切片中解组,则可以使用interface{}
。
import (
"fmt"
"encoding/json"
)
func main() {
strBytes := []byte(`[2,"19223201", "SomeString",{"SomeField": "FieldValue","SomeField2": "FieldValue2", "SomeFieldN": "FieldValueN"}]`)
keys := make([]interface{},0)
json.Unmarshal(strBytes, &keys)
fmt.Println(keys)
}