SJSON is a complement to GJSON, also written in Go, focused on setting or modifying values inside JSON documents through path expressions. Just as GJSON allows fast retrieval, SJSON allows fast mutation: you provide a JSON document, a dot-notation path (including array indices or the special “-1” index for appending), and a new value, and SJSON produces the updated JSON. It supports many data types (numbers, strings, bools, arrays, maps), raw byte paths, and options for in-place replacement. Because it avoids full unmarshalling into structs, it is very efficient for many use-cases where you just need to tweak a JSON document quickly. Paths support appending to arrays, creating intermediate structures if missing, and deleting (via the Delete function). It’s ideal for manipulating JSON dynamically in Go without bulky models.
Features
- Set a value in JSON given a path (dot notation)
- Append to arrays via special -1 index usage
- Delete values via path expression
- Works with raw bytes or string representations of JSON
- Support for SetRaw to inject raw JSON blocks
- Options for in-place replacement to reduce allocations