@@ -277,6 +277,32 @@ cargo run --quiet --package goth-cli -- ../examples/crypto/hashfile.goth /tmp/te
277277
278278---
279279
280+ ## json/
281+
282+ JSON parsing and serialization — pure Goth implementation using recursive descent parsing and fold-based serialization. All functions are implemented entirely in Goth via the ` json.goth ` standard library.
283+
284+ | File | Description | Example |
285+ | ------| -------------| ---------|
286+ | ` parse_simple.goth ` | Parse JSON, extract fields, serialize | ` parseJson "{\"name\":\"Goth\"}" → ⟨⊤, ..., ""⟩ ` |
287+ | ` roundtrip.goth ` | Parse → serialize → re-parse roundtrip test | ` toJson (parseJson input).1 ` |
288+
289+ ``` sh
290+ # Parse and extract fields from JSON
291+ cargo run --quiet --package goth-cli -- ../examples/json/parse_simple.goth
292+ # Name: Goth
293+ # Version: 1
294+ # Features: 3
295+ # ...
296+
297+ # Roundtrip: parse → serialize → parse → serialize
298+ cargo run --quiet --package goth-cli -- ../examples/json/roundtrip.goth
299+ # Roundtrip: PASS
300+ ```
301+
302+ ** Demonstrates:** Recursive descent parsing, ` chars ` , ` fromChars ` , ` parseFloat ` , fold-based string building, tagged tuples as sum types, ` strEq ` , ` use ` imports.
303+
304+ ---
305+
280306## Language Features Covered
281307
282308| Feature | Examples |
@@ -291,13 +317,13 @@ cargo run --quiet --package goth-cli -- ../examples/crypto/hashfile.goth /tmp/te
291317| Sum/Product (` Σ ` /` Π ` ) | numeric, higher-order, simulation |
292318| Iota (` ι ` ) | numeric, simulation |
293319| Array concat (` ⊕ ` ) | higher-order |
294- | String concat (` ⧺ ` ) | simulation, crypto |
320+ | String concat (` ⧺ ` ) | simulation, crypto, json |
295321| Conditionals (` if/then/else ` ) | basic, recursion, algorithms |
296322| Contracts (` ⊢ ` /` ⊨ ` ) | contracts, random |
297323| Uncertainty (` ± ` ) | uncertainty |
298324| File I/O (` ▷ ` , ` writeFile ` , ` readFile ` ) | io, simulation, crypto |
299- | Module imports (` use ` ) | simulation, random, crypto |
325+ | Module imports (` use ` ) | simulation, random, crypto, json |
300326| Tail-call optimization | tco |
301327| Bitwise ops (` bitand ` , ` bitor ` , ` bitxor ` , ` shl ` , ` shr ` ) | crypto |
302- | Tuple destructuring (` ⟨a, b⟩ ` ) | random |
328+ | Tuple destructuring (` ⟨a, b⟩ ` ) | random, json |
303329| PRNG / entropy | random |
0 commit comments