0.0.8 • Published 2 years ago
json-sorter-cli v0.0.8
JSON Sorter CLI
Yet, another one CLI tool to sort keys in JSON files.
Install
npm install --save-dev json-sorter-cli
CLI Usage
Format
json-sorter-cli [options] <string...>
Example
json-sorter-cli ./path/to.json ./path/to/**.json
Help
json-sorter --help
Why?
The main feature of this tool is that it does not use JSON.parse/JSON.stringify which might cause unescaping of Unicode escaped characters. For example, the ampersand character could be written as &
and as \u0026
, and both values are equal.
const a = JSON.parse(`"&"`);
const b = JSON.parse(`"\\u0026"`);
console.log('a', a);
console.log('b', b);
console.log('is equal', a === b);
The result is:
a &
b &
is equal true
This tool does not change values and leaves them as they are written.