# canonicaljson

> JS library for producing JSON in canonical format

Latest version **1.0.1** (published 2018-03-15) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install canonicaljson
pnpm add canonicaljson
yarn add canonicaljson
bun add canonicaljson
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-03-15 |
| First published | 2017-10-27 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 157.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Stratumn team |
| Maintainers | adrien-stratumn, simonvadee |
| Keywords | stratumn, canonical, json, js |

## Links

- npm: https://www.npmjs.com/package/canonicaljson
- Repository: https://github.com/stratumn/canonicaljson-js
- Homepage: https://github.com/stratumn/canonicaljson-js#readme
- Issues: https://github.com/stratumn/canonicaljson-js/issues
- npm.io page: https://npm.io/package/canonicaljson

## Dependencies (1)

- [bignumber.js](https://npm.io/package/bignumber.js.md) ^4.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-03-15
- 1.0.0 — 2017-12-01
- 1.0.0-alpha.1 — 2017-10-27

## README

# canonicaljson-js

JS library for producing JSON in canonical format as specified by https://gibson042.github.io/canonicaljson-spec/. The provided interface matches that of native JSON object.

[![npm](https://img.shields.io/npm/v/canonicaljson.svg)](https://www.npmjs.com/package/canonicaljson)
[![build status](https://travis-ci.org/stratumn/canonicaljson-js.svg?branch=master)](https://travis-ci.org/stratumn/canonicaljson-js)
[![codecov](https://codecov.io/gh/stratumn/canonicaljson-js/branch/master/graph/badge.svg)](https://codecov.io/gh/stratumn/canonicaljson-js)

## Installation

```bash
npm install canonicaljson
```

or

```bash
yarn add canonicaljson
```

## Usage

```bash
const json = require('canonicaljson');

const obj = json.parse('{ "a": 12 }');
console.log(json.stringify(obj))

// or if you use ES6 modules
import { parse, stringify } from 'canonicaljson';

const obj = parse('{ "a": 12 }');
console.log(stringify(obj))
```


## Development

Integration tests are located in the `canonicaljson-spec` submodule.
To download them, you should run:

```bash
git submodule init
git submodule update
```

### macOS

The tests need a version of `readlink` that support the `-v` option.
Macports and homebrew provide a coreutils package containing greadlink (GNU readlink).

You can do, for instance:

```bash
brew install coreutils

# in your .bashrc, .zshrc...
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
```

The tests also need the GNU version of `awk`. It is provided by homebrew:

```bash
brew install gawk
```

The tests will run if you change `#!/usr/bin/awk -f` to `#!/usr/local/bin/gawk -f` in `canonicaljson-spec/test/prettyjson.awk`:

```bash
sed -i "" s_/usr/bin/awk_/usr/local/bin/gawk_ canonicaljson-spec/test/prettyjson.awk
```

This change will be ignored by `git`.

---
_Source: https://npm.io/package/canonicaljson · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
