Esempio n. 1
1
func ExampleRead() {
	raw := []byte(`{"hello":"world"}`)

	var data interface{}
	json.Unmarshal(raw, &data)

	out, err := jsonpath.Read(data, "$.hello")
	if err != nil {
		panic(err)
	}

	fmt.Print(out)
	// Output: world
}
Esempio n. 2
0
func getPath(chain *chain, value interface{}, path string) *Value {
	if chain.failed() {
		return &Value{*chain, nil}
	}

	result, err := jsonpath.Read(value, path)
	if err != nil {
		chain.fail(err.Error())
		return &Value{*chain, nil}
	}

	return &Value{*chain, result}
}