項目地址:git
https://github.com/alibaba/jsonqgithub
示例jsonjson
{ "foo": 1, "bar": 2, "test": "Hello, world!", "baz": 123.1, "array": [ {"foo": 1}, {"bar": 2}, {"baz": 3} ], "subobj": { "foo": 1, "subarray": [1,2,3], "subsubobj": { "bar": 2, "baz": 3, "array": ["hello", "world"] } }, "bool": true }
調用spa
import ( "strings" "encoding/json" "github.com/jmoiron/jsonq" ) data := map[string]interface{}{} dec := json.NewDecoder(strings.NewReader(jsonstring)) dec.Decode(&data) jq := jsonq.NewQuery(data)