-
Notifications
You must be signed in to change notification settings - Fork 139
Home
Saddam H edited this page Mar 11, 2020
·
10 revisions
GoJSONQ provides simple, elegant and fast ODM like API to access/query JSON, YAML, XML, CSV data.
Let's have a first look:
package main
import (
"fmt"
gojsonq "github.com/thedevsaddam/gojsonq/v2"
)
func main() {
const jsonStr = `{"movies":[{"name":"Pirates of the Caribbean","sequels":[{"name":"The Curse of the Black Pearl","released":2003},{"name":"Dead Men Tell No Tales","released":2017}]}]}`
jq := gojsonq.New().JSONString(jsonStr)
name := jq.Find("movies.[0].name")
fmt.Println("name: ", name) // name: Pirates of the Caribbean
fsequel := jq.Reset().Find("movies.[0].sequels.[0].name")
fmt.Println("first sequel: ", fsequel) // first sequel: The Curse of the Black Pearl
}
Deeply nested JSON property can be grabbed easily!
Let's find more API details in Queries page
If you find the package useful please don't forget to star the repository