hapiman / jsrice

A common utils using in javascript
0 stars 0 forks source link

golang中json处理 #33

Closed hapiman closed 6 years ago

hapiman commented 6 years ago

如何不先定义解析的数据结构,直接访问数据 使用 import github.com/bitly/go-simplejson即可

示例

js, err := NewJson([]byte(`{
    "test": {
        "array": [1, "2", 3],
        "int": 10,
        "float": 5.150,
        "bignum": 9223372036854775807,
        "string": "simplejson",
        "bool": true
    }
}`))

arr, _ := js.Get("test").Get("array").Array()
i, _ := js.Get("test").Get("int").Int()
ms := js.Get("test").Get("string").MustString()