Skip to content

jsonquery

276 1 6 MIT
v1.3.7 (30 Mar 2026) Oct 15 2019 58.1 thousand (month)

jsonquery is a Go library that allows you to parse and extract data from JSON documents using JSONPath expressions. JSONPath is similar to XPath, but it is designed specifically for working with JSON documents.

The jsonquery library allows you to traverse the JSON tree structure and extract values using JSONPath expressions. It provides a simple and intuitive API for querying the JSON data, and it is built on top of the popular jsoniter library.

Example Use


```go package main

import ( "fmt" "log"

"github.com/antchfx/jsonquery" )

func main() { // Parse the JSON string doc, err := jsonquery.Parse([]byte({ "name": "John Doe", "age": 30, "address": { "street": "Main St", "city": "Anytown", "state": "CA", "zip": "12345" }, "phones": [ "555-555-5555", "555-555-5556" ] })) if err != nil { log.Fatal(err) }

// Extract the name name := jsonquery.FindOne(doc, "name") fmt.Println(name.InnerText()) // "John Doe"

// Extract the city city := jsonquery.FindOne(doc, "address.city") fmt.Println(city.InnerText()) // "Anytown"

// Extract all phone numbers phones := jsonquery.Find(doc, "phones[*]") for _, phone := range phones { fmt.Println(phone.InnerText()) } // "555-555-5555" // "555-555-5556" } ```

Alternatives / Similar


mxj
633 per (2023-07-24 15:10:09 ago) Feb 09 2017 compare

Other Languages

728 1.8.0 (2026-02-28 00:53:19 ago) Feb 09 2022 compare
2,424 1.1.0 (2026-01-22 16:35:24 ago) Feb 09 2022 compare
403 2.0.0 (2025-03-03 23:10:00 ago) Dec 03 2013 compare
209 0.2.25 (2022-07-06 18:55:03 ago) Feb 09 2022 compare
Was this page helpful?