{"name":"sorted-json","version":"0.2.3","keywords":["json","sortify","stringify","sort"],"author":{"name":"Yiling Zhou","email":"pastgift@gmail.com"},"license":"MIT","_id":"sorted-json@0.2.3","maintainers":[{"name":"pastgift","email":"pastgift@gmail.com"}],"homepage":"https://github.com/pastgift/sorted-json-js","bugs":{"url":"https://github.com/pastgift/sorted-json-js/issues"},"dist":{"shasum":"969cea164c01d67e7e013c5399a93b8fdfd8c721","tarball":"http://registry-npm.ywwl.com/sorted-json/download/sorted-json-0.2.3.tgz","fileCount":5,"integrity":"sha512-/tzmrQVr7NZm08s4OaHFNYNKXdeweE+JqfJemhpZ//+yWb/1CE2Khjfz5chyl4WyVwD6DL4fYE8pW5ZDk8+oPw==","signatures":[{"sig":"MEYCIQCgN1t9GYbxmDKC/tcD+y2mw82ehSZVlSdf1LvSrF9fkwIhAK2gBioFjGIU8qyk+CnWiEoAdVrP/2RkrEyhzZUI8CjV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9492,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbq202CRA9TVsSAnZWagAAX4IP/A+yc9HrtoH0BleLVi/q\nc6qafpdrTc79lhRy7dIZhjSCrt5vRrvMN2Sj4ay+1njAIfupMPaeZfeg6FD3\nCeSPHeq/9vZ1eREwntMOu1f9QfBgdk+iowrfcAa7kIAOToTdbZhVUAQ0xNXj\nYDbq89oxsZFbybQI0JkOuA6TQUMJ5ljiOzbcQwF+oCZpVI7/911iZIxMx4CJ\nn1OjFnZ4+e7muM4HGSj1MIbM5gK4N2ltDlaIQ5s1YzbbbRIrIk9toAdiQeNJ\neOXOyflDMjFwlakifahxdn7s2+tvt8BZ5oOz8xV9ulStgyK6LN5WDm7sKp5r\ndCOHlT10Beqk3HTFhH7hP2Oxg0A+CRZcIzILsyAF3QvmgQ+m4I9Wu1Atz4fV\n/+EKD/ZL+MoDUWgu3ApHbvEHus7wzqLtVhS5dWPWofi8fqkSByivKaX6sdgH\ng+S2s4Ednyp/eMgPZeR3f69ROgXUR6ApW1M5j0EPL849hUsSj/oVSTYqQt0X\noSap8JwkIBpt/ru+4MezMGu5RDjPszSSATK71FooIm4gb1Vp0t1n7DESuR/a\nLFiuPrZIbRgD6gtag1/aZvmxfsetMpOz41Rt5H6PMCZmyAE0MfNrDaPh5S10\nnXK4QlBWxcpX6Dyh7h4mkfiLfyjg47dXS2nwF4B9dav1hNw2T1EpWBPiBzXz\nMnOP\r\n=+79H\r\n-----END PGP SIGNATURE-----\r\n","size":3121,"noattachment":false,"key":"/sorted-json/-/sorted-json-0.2.3.tgz"},"main":"sorted-json.js","gitHead":"887a46b1efa1b7944c90e3aa7eb6b92ca7e3a8ca","scripts":{"test":"mocha"},"_npmUser":{"name":"pastgift","email":"pastgift@gmail.com"},"repository":{"url":"git+https://github.com/pastgift/sorted-json-js.git","type":"git"},"_npmVersion":"5.6.0","description":"Sort keys and array elements in a JSON.","directories":{},"_nodeVersion":"8.11.2","_hasShrinkwrap":false,"devDependencies":{"mocha":"2.0.1"},"_npmOperationalInternal":{"tmp":"tmp/sorted-json_0.2.3_1537961269579_0.9946570702401731","host":"s3://npm-registry-packages"},"readme":"# sorted-json-js\n\nSort keys and array elements in a JSON.\n\n## Quick Example 1:\n\nUsing `.sortify(...)` with `{ sortArray: true }` options to sort an object:\n\n```js\nvar sortedJSON = require('sorted-json');\n\nvar obj_1 = {\n  numberArray: [3, 1, 2],\n  anotherJSON: {\n    stringArray: ['cat', 'book', 'apple'],\n    numberA: 2,\n    numberB: 1\n  },\n  number1: 2,\n  number2: 1\n};\nconsole.log(sortedJSON.sortify(obj_1, { sortArray: true }));\n```\n\nOutput:\n\n```text\n{\n  anotherJSON: { numberA: 2, numberB: 1, stringArray: [ 'apple', 'book', 'cat' ] },\n  number1: 2,\n  number2: 1,\n  numberArray: [ 1, 2, 3 ]\n}\n```\n\n## Quick Example 2:\n\nUsing `.stringify(...)` to get a sorted JSON string:\n\n```js\nvar obj_2 = {\n  numberArray: [3, 1, 2],\n  anotherJSON: {\n    stringArray: ['cat', 'book', 'apple'],\n    numberA: 2,\n    numberB: 1\n  },\n  number1: 2,\n  number2: 1\n};\nconsole.log(sortedJSON.stringify(obj_2));\n```\n\nOutput:\n\n```text\n{\"anotherJSON\":{\"numberA\":2,\"numberB\":1,\"stringArray\":[\"cat\",\"book\",\"apple\"]},\"number1\":2,\"number2\":1,\"numberArray\":[3,1,2]}\n```\n\n# API:\n\n### .sortify(obj [, options])\n\nSort an object and return it.\n\n| Parameter           | Type     | Required | Default     | Description                                                                                                                      |\n| ------------------- | -------- | -------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| `obj`               | object   | Yes      |             | The object to sort                                                                                                               |\n| `options`           | object   |          | `{}`        | Sort options                                                                                                                     |\n| `options.sortBy`    | function |          | `undefined` | Specifies a function that defines the sort order. Same to `compareFunction` parameter in `Array.prototype.sort(compareFunction)` |\n| `options.sortKey`   | boolean  |          | `true`      | Sort the keys in `obj` or not                                                                                                    |\n| `options.sortArray` | boolean  |          | `true`      | Sort the array elements in `obj or not                                                                                           |\n| `options.stringify` | boolean  |          | `false`     | Output the stringified `obj` or not (Using `JSON.stringify()`)                                                                   |\n| `options.replacer`  |          |          |             | Parameter for `JSON.stringify()`                                                                                                 |\n| `options.space`     |          |          |             | Parameter for `JSON.stringify()`                                                                                                 |\n\n### .stringify(obj)\n\n| Parameter | Type   | Required | Default | Description        |\n| --------- | ------ | -------- | ------- | ------------------ |\n| `obj`     | object | Yes      |         | The object to sort |\n\n# Install:\n\n```shell\nnpm install sorted-json\n```\n\n# Test:\n\n```shell\nnpm test\n```\n\n# License\n\n[MIT](LICENSE)\n\n[downloads-image]: http://img.shields.io/npm/dm/sorted-json.svg\n\n[npm-url]: https://npmjs.org/package/sorted-json\n[npm-image]: http://img.shields.io/npm/v/sorted-json.svg\n","publish_time":1537961269722,"_cnpm_publish_time":1537961269722,"dist-tags":{"latest":"0.3.0"}}