AtlatestRenderedmarkdown
Readme

sigil-json

JSON parsing and generation for Sigil.

Bidirectional conversion between JSON and native Scheme types (dicts, arrays, strings, numbers, booleans) with port-based I/O for reading and writing JSON streams.

This package was extracted from the sigil monorepo — the in-tree history under packages/sigil-json/ is preserved here as master.

Usage

(import (sigil json))

;; Encode
(json-encode #{ name: "Alice" age: 30 })
; => "{\"name\":\"Alice\",\"age\":30}"

;; Decode
(json-decode "{\"name\":\"Alice\",\"age\":30}")
; => #{ name: "Alice" age: 30 }

;; Path lookup
(json-get-in (json-decode "{\"a\":{\"b\":42}}") '(a b))
; => 42

Type Mapping

JSONScheme
objectdict: #{ name: "Alice" }
arrayarray: #[1 2 3]
stringstring: "hello"
numbernumber: 42, 3.14
true#t
false#f
null'null symbol

JSON null decodes as the symbol 'null (not #f). When a field may be JSON null, normalize it explicitly — see docs/json.md for the pattern.

API

(sigil json)

ProcedurePurpose
json-encodeScheme value → JSON string
json-decodeJSON string → Scheme value
json-read / json-writePort-based streaming I/O
json-get-inPath lookup into a decoded value

See docs/json.md for full details.

Dependencies

  • sigil-stdlib

Consumed here as a from-git ref pinned to ^0.13.1 against the sigil monorepo.

Build

sigil deps install
sigil build

Testing

sigil test

License

BSD-3-Clause.