JSON parsing and generation for Sigil.
- Scheme 100%
|
David Wilson
55c9e74712
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Update the package version and Sigil compatibility range to 0.16, then regenerate the lockfile against sigil-stdlib ^0.16. Verification: - /tmp/sigil-t-e6e9/build/dev/bin/sigil deps install - /tmp/sigil-t-e6e9/build/dev/bin/sigil build - /tmp/sigil-t-e6e9/build/dev/bin/sigil test |
||
|---|---|---|
| docs | Add quick reference docs for sigil-json and sigil-http | |
| src/sigil | compiler: populate docs JSON exports from module at compile time | |
| test | fix: Handle surrogate pairs in JSON unicode escapes | |
| .gitignore | Extract sigil-json from sigil monorepo | |
| .woodpecker.yml | Bump CI pin to sigil v0.14.3 | |
| dev-redirects.sgl | Extract sigil-json from sigil monorepo | |
| manifest.scm | Extract sigil-json from sigil monorepo | |
| package.sgl | Bump sigil-json to Sigil 0.16 | |
| README.md | Extract sigil-json from sigil monorepo | |
| sigil.lock | Bump sigil-json to Sigil 0.16 | |
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
| JSON | Scheme |
|---|---|
| object | dict: #{ name: "Alice" } |
| array | array: #[1 2 3] |
| string | string: "hello" |
| number | number: 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)
| Procedure | Purpose |
|---|---|
json-encode |
Scheme value → JSON string |
json-decode |
JSON string → Scheme value |
json-read / json-write |
Port-based streaming I/O |
json-get-in |
Path 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.