module

Arcana::Canonical

JSON in one exact form, so a signature made over it in one program checks in another: RFC 8785, the JSON Canonicalization Scheme (JCS), which libraries in other languages implement too.

  • No whitespace.
  • Object keys sorted by their UTF-16 code units.
  • Strings escape only ", \ and control characters, as \b, \t, \n, \f, \r or \u00xx; everything else is written as is, in UTF-8.
  • Numbers as JavaScript writes them: the shortest digits that read back as the same double, in exponent form below 1e-6 and from 1e21 up (1e+21, 5e-324), 0 for -0. An integer beyond 2^53 is written as the double nearest it, as JavaScript would.

Class methods

json(value : JSON::Any) : String
Source
json(value : Hash(String, JSON::Any)) : String
Source