Liking cljdoc? Tell your friends :D

com.vadelabs.toon.encode.normalize

Data normalization for TOON encoding.

Converts Clojure data structures to JSON-compatible values:

  • Keywords → strings
  • Symbols → strings
  • Sets → vectors
  • Maps with keyword keys → maps with string keys
  • UUIDs → strings
  • Dates/Instants → ISO-8601 strings
  • NaN/Infinity → nil
  • Functions/vars → nil
Data normalization for TOON encoding.

Converts Clojure data structures to JSON-compatible values:
- Keywords → strings
- Symbols → strings
- Sets → vectors
- Maps with keyword keys → maps with string keys
- UUIDs → strings
- Dates/Instants → ISO-8601 strings
- NaN/Infinity → nil
- Functions/vars → nil
raw docstring

array-of-arrays?clj/s

(array-of-arrays? value)
source

array-of-objects?clj/s

(array-of-objects? value)
source

array-of-primitives?clj/s

(array-of-primitives? value)
source

json-array?clj/s

(json-array? value)
source

json-object?clj/s

(json-object? value)
source

normalize-valueclj/s

(normalize-value value)
(normalize-value value depth max-depth)

Normalizes a Clojure value to a JSON-compatible representation.

Normalization rules:

  • nil → nil
  • Booleans → unchanged
  • Strings → unchanged
  • Numbers:
    • Finite → unchanged (with -0 → 0)
    • NaN, Infinity, -Infinity → nil
  • Keywords → strings (e.g., :foo → "foo", :user/id → "user/id")
  • Symbols → strings (e.g., 'foo → "foo")
  • UUIDs → strings
  • Dates/Instants → ISO-8601 strings
  • BigInt/BigDecimal → number or string (if out of safe range)
  • Sets → vectors (sorted for determinism)
  • Maps → maps with string keys (recursively normalized values)
  • Vectors/Lists → vectors (recursively normalized)
  • Functions, vars, undefined → nil

Parameters:

  • value: Any Clojure value
  • depth: (optional) Current nesting depth (default: 0)
  • max-depth: (optional) Maximum nesting depth (default: 1000)

Returns: JSON-compatible value (nil, boolean, number, string, vector, or map)

Throws: ex-info if max-depth is exceeded to prevent stack overflow

Normalizes a Clojure value to a JSON-compatible representation.

Normalization rules:
- nil → nil
- Booleans → unchanged
- Strings → unchanged
- Numbers:
  - Finite → unchanged (with -0 → 0)
  - NaN, Infinity, -Infinity → nil
- Keywords → strings (e.g., :foo → "foo", :user/id → "user/id")
- Symbols → strings (e.g., 'foo → "foo")
- UUIDs → strings
- Dates/Instants → ISO-8601 strings
- BigInt/BigDecimal → number or string (if out of safe range)
- Sets → vectors (sorted for determinism)
- Maps → maps with string keys (recursively normalized values)
- Vectors/Lists → vectors (recursively normalized)
- Functions, vars, undefined → nil

Parameters:
  - value: Any Clojure value
  - depth: (optional) Current nesting depth (default: 0)
  - max-depth: (optional) Maximum nesting depth (default: 1000)

Returns:
  JSON-compatible value (nil, boolean, number, string, vector, or map)

Throws:
  ex-info if max-depth is exceeded to prevent stack overflow
sourceraw docstring

primitive?clj/s

(primitive? value)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close