//With the updated json parsing as of May 8, 2017, the speed of extraction from JSON string increased more than twice: //using old API it took 7.2 seconds, with new API, it took 2.3 sec) //the new API allows decoding JSON with a sequence of field names to specify the element to be extracted. package main import "time" import ( "fmt" "github.com/xiaost/jsonport" ) func main() { jsonstr := `{ "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 }`; sum := 1 t0 := time.Now() for sum < 1000000 { jsonport.Unmarshal([]byte(jsonstr), "subobj","subsubobj", "array", 1) sum += 1 } t1 := time.Now() fmt.Printf("The call took %v to run.\n", t1.Sub(t0)) }