go get github.com/krystalics/[email protected]
import "github.com/krystalics/jpath"
Let's see a quick example:
package main
import "github.com/krystalics/jpath"
func main() {
const json = `{"name":{"first":"lin","last":"jia"},"age":61}`
jPath, _ := jpath.New(json)
name,err := jPath.Find("name.first")
if err != nil {
return
}
//...
}
when you want to use jpath in concurrency situation
package main
import "github.com/krystalics/jpath"
func main() {
const json = `{"name":{"first":"lin","last":"jia"},"age":61}`
jPath, _ := jpath.NewConcurrencySafe(json)
for i := 0; i < 100; i++ {
go func() {
name,err := jPath.Find("name.first")
if err != nil {
return
}
//...
}()
}
}
The jpath is an open-source software licensed under the MIT License.