JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 656779
  • Score
    100M100P100Q227961F
  • License Apache-2.0

JSON canonicalize function

Package Exports

  • canonicalize

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (canonicalize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status Coverage Status

canonicalize

JSON canonicalize function. Creates crypto safe predictable canocalization of JSON as defined by RFC8785

Usage

Normal Example

JSON.canonicalize = require('canonicalize');
const  json = {
    "from_account": "543 232 625-3",
    "to_account": "321 567 636-4",
    "amount": 500,
    "currency": "USD"
}
console.log(JSON.canonicalize(json));
// output: {"amount":500,"currency":"USD","from_account":"543 232 625-3","to_account":"321 567 636-4"}

Crazy Example

JSON.canonicalize = require('canonicalize');
const  json = {
    "1": {"f": {"f":  "hi","F":  5} ,"\n":  56.0},
    "10": { },
    "":  "empty",
    "a": { },
    "111": [ {"e":  "yes","E":  "no" } ],
    "A": { }
}
console.log(JSON.canonicalize(json));
// output: {"":"empty","1":{"\n":56,"f":{"F":5,"f":"hi"}},"10":{},"111":[{"E":"no","e":"yes"}],"A":{},"a":{}}

Install

npm install canonicalize --save

Test

npm test