How goccy/go-json works
go-json is a Go JSON library intended as a fast, encoding/json-compatible replacement. Its main workflow accepts Go values through the public API, encodes them to JSON bytes or decodes JSON into Go values, while the jsontext package also exposes lower-level streaming and token-oriented JSON operations. The repository includes a v2 API, configurable behavior, type-safe field filtering, and colored encoding. The graph reflects documented capabilities and indexed dependencies; some implementation paths and links are inferred only from package documentation and are marked dashed.
Main entry points: context.go Encoder engine · arshal.go V2 API · json.go JSON API · marshal_to.go Writer API
Components 20
Public APIs
- JSON API
json.go - Encode API
encode.go - Decode API
decode.go - V2 API
v2/arshal.go - Writer API
v2/marshal_to.go - Field filtering
query.go
Encode and Decode
- Encoder engine
internal/encoder/context.go - Encoder VM
internal/encoder/vm/vm.go - Colored encoding
internal/encoder/vm_color/vm.go - Indented encoding
internal/encoder/vm_indent/vm.go - Decoder engine
internal/decoder/context.go - String decoding
internal/decoder/string.go
JSON Text
- Text decoder
jsontext/decode.go - Text encoder
jsontext/encode.go - Value scanner
jsontext/scan.go - Text operations
jsontext/text.go
Shared Support
- Struct field rules
internal/jsonfields/fields.go - Error handling
internal/errors/error.go - Options
internal/options/options.go
Other components
- Go caller
Connections 28
- Go caller → JSON API: calls
README.md - JSON API → Encoder engine: encodes with
json.go - JSON API → Decoder engine: decodes with
json.go - Go caller → Encode API: calls
README.md - Go caller → Decode API: calls
README.md - Encode API → Encoder engine: encodes with
- Decode API → Decoder engine: decodes with
- Encoder engine → Encoder VM: executes
- Encoder engine → Struct field rules: uses field rules
- Decoder engine → String decoding: decodes strings
internal/decoder/context.go - Go caller → V2 API: calls
README.md - V2 API → Encoder engine: encodes with
v2/arshal.go - V2 API → Text encoder: uses text encoder
v2/arshal.go - Go caller → Writer API: writes JSON
README.md - Writer API → Encoder engine: encodes with
v2/marshal_to.go - Writer API → Text encoder: writes through
v2/marshal_to.go - Go caller → Text decoder: streams JSON
jsontext/decode.go - Go caller → Text encoder: writes tokens
- Text decoder → Value scanner: scans values
- Go caller → Text operations: uses text operations
- JSON API → Error handling: reports errors
- V2 API → Error handling: reports errors
v2/arshal.go - Go caller → Field filtering: configures filtering
query.go - Field filtering → Encoder engine: sets field query
query.go - Go caller → Options: configures behavior
README.md - V2 API → Options: applies options
v2/arshal.go - Encoder engine → Colored encoding: supports coloring
- Encoder engine → Indented encoding: supports indentation