Skip to content
Saddam H edited this page Jun 20, 2018 · 10 revisions

What is GoJSONQ

GoJSONQ provides simple, elegant and fast ORM like API to access/query JSON document.

Let's have a first look:

package main

import (
	"fmt"

	"github.com/thedevsaddam/gojsonq"
)

func main() {
	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]")
	fmt.Println("first sequel: ", fsequel) // first sequel:  map[name:The Curse of the Black Pearl released:2003]
}

Deeply nested JSON property can be grabbed easily!