• Stars
    star
    357
  • Rank 119,149 (Top 3 %)
  • Language
    Haskell
  • Created almost 8 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Work in progress. Best alternative: https://matrix.org/docs/spec/appendices.html#canonical-json

Son

A subset of JSON.

JSON contains redundant syntax such as allowing both 10e2 and 10E2. This helps when writing it by hand but isn't good for machine-to-machine communication. Piping JSON through multiple programs creates lots of trivial changes, which makes it hard to do things like take meaningful diffs.

Son is a subset of JSON without redundant options. It's intended for machine-to-machine communication by programs that want to follow Postel's Law -- they can accept normal JSON for flexibility and output Son for consistency.

Son Numbers

Number

  • No exponential notation
  • No trailing zeros in fractions
  • No negative zero
  • No positive sign

positiveInteger:

Positive Integer

fraction:

Fraction

Son Strings

String

  • No unnecessary escape sequences

JSON doesn't allow Unicode characters below codepoint x20 or unescaped " and \ in strings. To allow these to still be encoded in JSON we've had to keep a few escape sequences. We use two-character escape sequences (e.g. \n) when available, and six-character ones (e.g. \u0001) when not.

shortcutEscape:

shortcutEscape

Other Changes from JSON

  • No insignificant whitespace

Status

Unreleased. Like JSON, the intention is that once Son is released it will never change.

Specification

The formal part of its specification is ./son.ebnf. It uses the EBNF notation described here.

Additionally:

  • The only valid byte encoding of Son is UTF-8. Byte order marks are forbidden.

  • Object keys must be unique.

  • Object members must be sorted by ascending lexicographic order of their keys.

Implementations

Special Thanks

Differences between this and related projects

See here.

Notes

  • The diagrams were generated with GrammKit.

  • ./vendored/rfc7159.txt is from here.