[英]Unmarshal array json in golang
How would I unmarshal something like this: 我如何解组这样的事情:
[
2,
"19223201",
"SomeString",
{
"SomeField": "FieldValue",
"SomeField2": "FieldValue2", "SomeFieldN": "FieldValueN", }
]
You can use interface{}
if you have not define any interface and unmarshal into interface type slice. 如果尚未定义任何接口并解组为接口类型slice,则可以使用
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)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.