sjson

A fast, dependency-light Go library for setting and deleting values in JSON documents by dot-path, without full unmarshaling.

Library
Go
vv1.2.5
2,738stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity16
Maintenance0
Community56
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
63/100Good
Architecture68
Code Quality72
Innovation58
Learning Curve55

SJSON is a Go package for setting and deleting values within a JSON document using a simple dot-syntax path, without needing to unmarshal the document into a Go struct or map first. It operates directly on the raw JSON bytes or string, rewriting only the affected region, which makes single-field updates to large JSON payloads significantly faster and more memory-efficient than a full decode-modify-encode round trip.

Paths support nested objects, array indexing, array appends via the -1 key, and escaped literal keys containing dots. Values can be set from any Go type — primitives, slices, maps, or arbitrary structs via the standard library’s encoding/json fallback — and an Optimistic mode with in-place byte replacement lets callers who know a key already exists skip most of the allocation overhead entirely. It pairs naturally with GJSON, the companion package by the same author for reading JSON values by path, and both are designed to be used together as a lightweight alternative to full unmarshal/marshal cycles.

What You Get

  • Path-based Set/Delete for JSON strings and byte slices via dot-syntax paths
  • Support for setting values of any Go type — primitives, slices, maps, and arbitrary structs (via json.Marshal fallback)
  • Array operations: index-based sets, out-of-bounds padding with null, and -1 append syntax
  • SetRaw/SetRawBytes for injecting pre-marshalled JSON blocks without double-encoding
  • An Optimistic + ReplaceInPlace option pair for near-zero-allocation in-place updates on existing keys

Common Use Cases

  • Patching a single field in a large JSON API response or config file without a full unmarshal
  • Building JSON payloads incrementally at CLI or middleware layers where defining a Go struct is unnecessary overhead
  • Rewriting config files or webhook bodies in place while preserving unrelated fields and formatting
  • Combining with GJSON for read-modify-write flows on JSON documents your program doesn’t otherwise model as Go types

Under The Hood

Architecture SJSON is a single flat package (sjson.go, ~750 lines) with no internal sub-packages or layering — appropriate for its narrow scope. Every public entry point (Set, SetBytes, SetRaw, Delete, and their Options variants) funnels into one private set() function, which parses the dot-syntax path into a slice of pathResult structs via parsePath, then either rewrites an existing value in place (appendRawPaths, using gjson.Get to locate the target byte range) or constructs new nested JSON structure from scratch (appendBuild). Path traversal and value location are delegated entirely to the sibling GJSON package rather than reimplemented, so SJSON’s own logic is essentially one recursive tree-rewrite algorithm layered on top of GJSON’s read path. Unsafe pointer casts between string and []byte headers avoid copies when converting between the string-based public API and the byte-slice internals.

Tech Stack Written in Go (module declares go 1.14), with exactly two runtime dependencies: github.com/tidwall/gjson (the companion read-path library used for locating values) and github.com/tidwall/pretty (used only in tests, for sorting/normalizing JSON during assertions). There is no web framework, ORM, or database — this is a pure, dependency-light algorithmic library. Build and CI are plain go build/go test via a GitHub Actions workflow (.github/workflows/go.yml) that checks out, fetches deps, builds, and runs the test suite on push and PR against master.

Code Quality The test suite (sjson_test.go, ~350 lines against ~750 lines of implementation) is table-driven, exercising Set, SetRaw, Delete, and their byte-slice variants through shared helper functions that normalize JSON before comparison. Errors are explicit and typed (a small errorType implementing the error interface) and propagated rather than swallowed — including from the encoding/json.Marshal fallback path for unrecognized value types. Naming follows idiomatic Go conventions (exported CamelCase, unexported lowerCamelCase), and CI runs go build plus go test on every push and PR, though there is no dedicated linter configuration in the repo.

What Makes It Unique SJSON’s core engineering bet is avoiding the decode-modify-encode round trip entirely: it rewrites only the byte range affected by a path update, and its Optimistic + ReplaceInPlace option pair goes further, mutating the caller’s byte slice directly via unsafe pointer tricks when a key is known to already exist — a deliberate, documented trade-off for near-zero-allocation updates in hot paths. This is a standard, well-understood technique (raw-byte JSON patching) rather than a novel algorithmic contribution, but the implementation is unusually disciplined about performance for a small, focused utility library.

Used by 10 apps in this directory

Go
75%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,299

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
69
Dependency
Built with
Go75%
TypeScript23%
Updated today
Go
98%
Other

Crush

Developer Tools · AI Code Assistants · AI Assistants

27,798

Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.

View details
87
Repo Health
86
Technical
69
Dependency
Built with
Go98%
Updated today
Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,298

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
90
Repo Health
9
Technical
67
Dependency
Built with
Go79%
Shell20%
Updated 2 days ago
Go
51%
AGPL 3.0

Filestash

File Storage

14,560

A self-hosted file management platform that unifies access to S3, SFTP, SMB, FTP, WebDAV, NFS, Git, SharePoint, and 20+ other storage backends through a single extensible web interface.

View details
79
Repo Health
67
Technical
66
Dependency
Built with
Go51%
JavaScript35%
Updated 3 days ago
Go
65%
Other

Hanko

Security · Authentication

9,016

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
69
Dependency
Built with
Go65%
TypeScript30%
Updated 2 days ago
Go
60%
MIT

Obot

AI Agents

965

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
87
Repo Health
70
Technical
70
Dependency
Built with
Go60%
Svelte29%
Updated yesterday
Go
48%
Apache 2.0

opencloud

File Storage

5,868

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

View details
85
Repo Health
80
Technical
69
Dependency
Built with
Go48%
Gherkin36%
PHP12%
Updated yesterday
Go
91%
Apache 2.0

Ory Kratos

Authentication

13,853

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

View details
84
Repo Health
78
Technical
67
Dependency
Built with
Go91%
Updated 1 months ago
Go
61%
Apache 2.0

OSV.dev

Security

2,902

Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.

View details
89
Repo Health
82
Technical
70
Dependency
Built with
Go61%
Python26%
Updated 2 days 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

Search