gjson

Fast, dependency-light JSON value extraction for Go using dot-notation paths.

Library
Go
vv1.20.0
15,554 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
68 /100 Good
Development Activity 68
Maintenance 24
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
70 /100 Good
Architecture 75
Code Quality 68
Innovation 72
Learning Curve 65

GJSON is a small, dependency-light Go library for reading values out of JSON strings and byte slices using a compact dot-notation path syntax. Instead of defining a struct and unmarshaling an entire payload, callers call gjson.Get(json, “friends.#(last==“Murphy”).first”) and get back a typed Result, with array queries, wildcards, and pipe-chained modifiers like @pretty and @reverse handled directly in the path string.

It has been in active development since 2016, ships a documented path-syntax reference (SYNTAX.md), pairs with a sibling library (SJSON) for writing values back into JSON, and includes a zero-copy GetBytes path aimed at services that parse large payloads on a hot path.

What You Get

  • Path-based value extraction (Get/GetBytes) that works directly on strings or byte slices without allocating a target struct.
  • Array query syntax (#(...), #(...)#) with comparison and pattern-matching operators for filtering nested arrays inline.
  • A library of pipe-chained modifiers (@pretty, @ugly, @reverse, @flatten, @group, @dig, @keys, @values) for reshaping results without extra code.
  • JSON Lines iteration (ForEachLine, the .. path prefix) for newline-delimited JSON documents.
  • A Result type with typed accessors (String/Int/Float/Bool/Time/Array/Map) plus Index/Indexes for locating matches in the source text.

Common Use Cases

  • Trimming large third-party API responses down to the handful of fields a service actually needs, without a matching struct.
  • Processing newline-delimited JSON logs with ForEachLine and the .. path prefix instead of a custom line-by-line unmarshal loop.
  • Inspecting or reshaping JSON with an unknown or dynamic schema, where path queries replace repeated map[string]interface{} type assertions.
  • Reading a handful of keys out of a larger JSON config file at startup without maintaining a full config struct.

Under The Hood

Architecture

The entire library lives in one flat file (gjson.go, ~3,700 lines) plus a companion test file, with the only two dependencies being tidwall/match (pattern matching for query filters) and tidwall/pretty (the @pretty/@ugly modifiers), both by the same author. Get(json, path) splits the dot-path via parseObjectPath/parseArrayPath, then parseObject/parseArray walk the raw JSON string byte-by-byte matching path segments without building an intermediate AST, returning Result structs whose Raw/Str/Num fields are sliced directly from the original input. Parsing and path-matching are deliberately fused into the same recursive walk rather than split into separate layers, which favors speed over modularity — changing the Result or path-parsing contract would touch most of the file.

Tech Stack

Written in Go (module targets go 1.23, and uses the newer iter package for range-over-func iterators), with go.mod declaring only tidwall/match v1.1.1 and tidwall/pretty v1.2.0 as external dependencies; everything else comes from the standard library (strconv, strings, time, unicode/utf16, unicode/utf8, unsafe). There’s no build tooling beyond go build/go test, and CI is a single GitHub Actions workflow that builds and tests on every push and PR to master. It’s distributed purely as an importable module, not a CLI (the companion jj command-line tool lives in a separate repository).

Code Quality

gjson_test.go contains 99 test functions and 3 benchmarks using only the standard testing package, covering path syntax edge cases, modifiers, JSON Lines, and the byte-level zero-copy behavior of GetBytes. Error handling is mostly implicit: malformed JSON doesn’t panic but silently returns zero-value Results rather than an error, and accessor methods favor forgiving empty-value fallbacks over strict validation, a deliberate ergonomics tradeoff for a no-error-checking query API. The GetBytes fast path uses unsafe.Pointer casts to avoid copying between string and []byte, a documented and contained optimization. Naming is consistent across the parseX/validX function families; CI runs build and test but no linter step is configured.

What Makes It Unique

The dot-notation path syntax supports inline array queries (#(age>45), #(last=="Murphy")#), wildcards, and pipe-chained modifiers (@reverse, @flatten, @group, @dig, and more), letting callers extract or reshape deeply nested values in a single expression instead of unmarshaling into a struct or writing manual type assertions. The zero-copy GetBytes path and per-match Index/Indexes tracking (for locating a matched value back in the original source text) are low-level techniques not commonly found together in comparable Go JSON libraries.

Used by 22 apps in this directory

Go
69%
Other

Hanko

Authentication · Security

9,038

Open source, self-hostable authentication platform with passkeys, SAML SSO, and OAuth — the privacy-first alternative to Auth0 and Clerk.

View details
89
Repo Health
81
Technical
66
Dependency
Built with
Go 69%
TypeScript 27%
Updated 2 weeks ago
Go
97%
Apache 2.0

infracost

Developer Tools · Devops

12,560

Infracost shows cloud cost estimates for Terraform, CloudFormation, and AWS CDK before you deploy — in your terminal, editor, AI coding agent, and pull requests.

View details
82
Repo Health
78
Technical
67
Dependency
Built with
Go 97%
Updated 2 weeks ago
Go
95%
MIT

cli

Developer Tools · Team Chat

17,597

The official Lark/Feishu CLI tool built for both humans and AI agents, delivering 200+ commands and 26 AI agent skills across 18 business domains from messaging and calendar to docs, sheets, and approvals.

View details
84
Repo Health
83
Technical
75
Dependency
Built with
Go 95%
Updated 2 weeks ago
Go
47%
GPL 3.0

Netdata

Devops · Monitoring

80,863

Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.

View details
93
Repo Health
86
Technical
70
Dependency
Built with
Go 47%
C 29%
Rust 15%
Updated 1 weeks ago
Go
98%
Apache 2.0

Nightingale

Monitoring

13,327

Open-source alerting engine that connects to any time-series or log data source and routes alarms to 20+ notification channels with AI-assisted triage.

View details
96
Repo Health
77
Technical
67
Dependency
Built with
Go 98%
Updated 1 weeks ago
Go
74%
Other

Notifuse

Marketing

2,240

Open-source, self-hosted alternative to Mailchimp, Brevo, and Klaviyo — send newsletters and transactional emails without per-email pricing or vendor lock-in.

View details
81
Repo Health
80
Technical
65
Dependency
Built with
Go 74%
TypeScript 23%
Updated 3 weeks ago
Go
64%
MIT

Obot

AI Agents · Mcp

1,099

An open-source MCP platform for organizations — host MCP servers, run MCP registries, monitor usage, and build agents and chatbots on top of the Model Context Protocol from one self-hosted deployment.

View details
88
Repo Health
70
Technical
70
Dependency
Built with
Go 64%
Svelte 23%
TypeScript 13%
Updated 1 weeks ago
Go
51%
Apache 2.0

opencloud

File Storage

6,120

Open source file management and collaboration platform that keeps your data under your control, no database required.

View details
86
Repo Health
80
Technical
68
Dependency
Built with
Go 51%
Gherkin 34%
PHP 11%
Updated 2 weeks ago
Go
91%
Apache 2.0

Ory Kratos

Authentication

13,913

API-first identity and user management that handles login, registration, MFA, and recovery so your application never has to.

View details
79
Repo Health
78
Technical
65
Dependency
Built with
Go 91%
Updated 2 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers