jsonparser reads fields from JSON byte slices without structs, using path keys and minimal allocations. A ReaderParser streams from io.Reader for large documents.
Overview
jsonparser targets Go programs that must pull specific fields from JSON without unmarshaling entire documents into typed structs. Path-based Get, GetString, GetInt, and related helpers return values, types, and offsets into the original buffer.
The package emphasizes speed and low allocation compared with encoding/json for selective access. EachArray and EachArrayErr walk arrays with callbacks, and Set or Delete mutate buffers in place for simple editing tasks.
ReaderParser applies the same path model to streaming input with a sliding window, configurable max buffer size, and optional lenient modes for single quotes or unknown escapes via Config.
Formal verification work cited in project materials traces requirements, fuzzing, and MC/DC coverage for the parser implementation.
Key features
- Path-based field extraction without structs
- Low-allocation parsing in Go
- ReaderParser for streaming io.Reader input
- Array and object iteration helpers
- In-place Set and Delete on byte buffers
- Strict and lenient parsing configs
Use cases
- Parse unpredictable third-party JSON APIs
- Scan large JSON logs for single fields
- Avoid defining structs for dynamic payloads