Formata.Codec.JSON (formata v0.1.0)

Copy Markdown View Source

JSON codec backed by Formata.Jason.

Decoding

  • Any JSON value may be the root (objects, arrays, and scalars).
  • Object keys stay strings.
  • Duplicate object keys are rejected with a :parse / :duplicate_key error (RFC 8259 leaves their meaning undefined; Formata does not pick one).
  • Numbers become integers or floats; numbers outside the float range are a syntax error reported by Formata.Jason.
  • Syntax errors carry the byte offset reported by Formata.Jason and the line/column derived from it.

Options: none.

Encoding

The JSON domain is nil, booleans, integers, finite floats, UTF-8 strings, lists, and maps with string keys. Atom keys, Date/DateTime values, :infinity/:nan, tuples, and other terms are rejected; convert them explicitly with Formata.Transform.

Options:

  • :pretty - pretty-print the output (default false).