A Go package for fast and simple retrieval of values from JSON documents using path syntax.
GJSON is a Go library for efficiently extracting values from JSON data using a dot-notation path syntax. It provides a fast, single-line API for read-only operations, avoiding the overhead of full unmarshaling when only specific values are needed.
Go developers who need to parse large JSON documents or frequently query JSON data for specific values, such as those working with APIs, configuration files, or log data.
Developers choose GJSON for its performance, with zero allocations in common cases and faster query times compared to standard Go JSON parsing, and its simplicity with a concise path-based query language that includes wildcards, array queries, and modifiers.
Get JSON values quickly - JSON parser for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks show GJSON outperforms standard Go JSON parsing with zero allocations in common cases, making it ideal for high-throughput read operations.
The dot-notation with wildcards, array queries, and modifiers allows complex JSON extraction in a single line, reducing boilerplate code.
Includes built-in modifiers for transformations, JSON Lines support, and query capabilities with conditions like equality and pattern matching.
Optimized to avoid unnecessary allocations, which is critical for processing large JSON documents or in memory-constrained environments.
GJSON cannot modify JSON; for writes, you must use the separate SJSON library, adding complexity and potential integration overhead.
The non-standard path syntax requires learning and can make codebase migration away from GJSON difficult if needs change.
The README notes a syntax change in v1.3.0 for queries, indicating potential backward compatibility issues that could disrupt upgrades.