{"_id":"@bencuk/jsonlint","_rev":"2-edd9e87c76411a59f5d69332bf288d6d","name":"@bencuk/jsonlint","dist-tags":{"latest":"10.2.1-fork"},"versions":{"0.0.0-development":{"name":"@bencuk/jsonlint","publishConfig":{"access":"public"},"version":"0.0.0-development","description":"JSON/CJSON/JSON5 parser, syntax and schema validator and pretty-printer.","author":{"name":"Ferdinand Prantl","email":"prantlf@gmail.com","url":"http://prantl.tk"},"contributors":[{"name":"Greg Inman","email":"ginman@itriagehealth.com"},{"name":"Paul Vollmer","email":"mail@paulvollmer.net","url":"http://paulvollmer.net"},{"name":"Zach Carter","email":"zach@carter.name","url":"http://zaa.ch"}],"license":"MIT","licenses":[{"type":"MIT","url":"https://github.com/prantlf/jsonlint/blob/master/LICENSE"}],"homepage":"http://prantlf.github.com/jsonlint/","repository":{"type":"git","url":"git+https://github.com/prantlf/jsonlint.git"},"bugs":{"url":"http://github.com/prantlf/jsonlint/issues"},"preferGlobal":true,"main":"lib/jsonlint.js","typings":"lib/jsonlint.d.ts","bin":{"jsonlint":"lib/cli.js"},"engines":{"node":">= 6"},"scripts":{"prepare":"npm run lint && npm run build","lint":"npm run lint:js && npm run lint:ts","lint:js":"standard --fix -v","lint:ts":"tslint --fix -t stylish lib/*.ts test/*.ts","build":"npm run compile && npm run compile:tests","compile":"node scripts/bundle-jsonlint && uglifyjs -o web/jsonlint.min.js --source-map \"filename='jsonlint.js',url='jsonlint.min.js.map',includeSources=true\" lib/jsonlint.js && uglifyjs -o web/validator.min.js --source-map \"filename='validator.js',url='validator.min.js.map',includeSources=true\" lib/validator.js && uglifyjs -o web/formatter.min.js --source-map \"filename='formatter.js',url='formatter.min.js.map',includeSources=true\" lib/formatter.js && uglifyjs -o web/sorter.min.js --source-map \"filename='sorter.js',url='sorter.min.js.map',includeSources=true\" lib/sorter.js && uglifyjs -o web/printer.min.js --source-map \"filename='printer.js',url='printer.min.js.map',includeSources=true\" lib/printer.js && node scripts/bundle-schema-drafts && uglifyjs -o web/schema-drafts.min.js --source-map \"filename='schema-drafts.js',url='schema-drafts.min.js.map',includeSources=true\" lib/schema-drafts.js && uglifyjs -o web/ajv.min.js --source-map \"filename='ajv.js',url='ajv.min.js.map',includeSources=true\" node_modules/ajv/dist/ajv.bundle.js","compile:tests":"tsc --lib es6 test/typings.test.ts","test":"nyc --silent node test/typings.test.js && nyc --silent --no-clean node test/parse1 && nyc --silent --no-clean node test/parse1 --native-parser && nyc --silent --no-clean node test/parse2 && nyc --silent --no-clean node test/parse3 && nyc --silent --no-clean node test/parse4 && nyc --silent --no-clean node test/parse5 && nyc --silent --no-clean node test/portable && nyc --silent --no-clean node test/tokenize && nyc --silent --no-clean node test/print && nyc --silent --no-clean node lib/cli package.json test/recursive && nyc --silent --no-clean node lib/cli -sq test/passes/hasOwnProperty.json && nyc --silent --no-clean node lib/cli -s -e json-schema-draft-04 -V test/passes/3.schema.json test/passes/3.json && nyc --silent --no-clean node lib/cli -C test/passes/comments.txt && nyc --silent --no-clean node lib/cli -pS test/passes/strings.txt && nyc --silent --no-clean node lib/cli -M json5 test/passes/json5.text && nyc --silent --no-clean node lib/cli -v && nyc --silent --no-clean node lib/cli -h && nyc --silent --no-clean node lib/cli -Pc test/fails/10.json || nyc report","start":"http-server -c 5","web":"npm run web:sync && npm run web:deploy","web:clone":"test ! -d ../jsonlint-pages && git clone --single-branch --branch gh-pages `git remote get-url origin` ../jsonlint-pages","web:pull":"cd ../jsonlint-pages && git pull","web:sync":"cp web/*.min.* ../jsonlint-pages/ && cp web/jsonlint.html ../jsonlint-pages/index.html","web:deploy":"cd ../jsonlint-pages && git commit -a -m 'Deploy site updates' && git push origin gh-pages"},"standard":{"ignore":["benchmarks/jison","benchmarks/pegjs","jsonlint*.js","test/fails","test/passes","test/recursive","test/v8"]},"keywords":["json","validation","lint","jsonlint"],"dependencies":{"ajv":"6.10.2","commander":"4.0.1"},"devDependencies":{"@types/node":"13.1.1","http-server":"0.12.0","js-yaml":"3.13.1","nyc":"15.0.0","standard":"14.3.1","test":"0.6.0","tslint":"5.20.1","tslint-config-standard":"9.0.0","typescript":"3.7.4","uglify-js":"3.7.3"},"gitHead":"a74ee2f42a87cfa60664e9dd17787d81abe25a82","_id":"@bencuk/jsonlint@0.0.0-development","_nodeVersion":"12.16.1","_npmVersion":"6.13.1","dist":{"integrity":"sha512-syuUQaNG9r/rt3Oph7MLnXM3LF7Dp6wQ9HjxsVnjD/lCX7ZavD1D+n7xmBSJsyriXTPZc0CYOh5Va4bZkx81Yw==","shasum":"4304f46d3e8cd17f5a97b156baabbce9462a42a9","tarball":"https://registry.npmjs.org/@bencuk/jsonlint/-/jsonlint-0.0.0-development.tgz","fileCount":28,"unpackedSize":890469,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebfq8CRA9TVsSAnZWagAAPZwP+wQwGN1jh/Hm88OAqmiZ\np2laDtWCMd08vGAlD/A31uJLugWpkXKSBQNThw/yVUNvUhsk8WNeypzpPKky\ng3csJJNWFu7nSByhQIJCxP4Yk8rj3udQb8eZFZebZmm9xbCdAXsdhQbkGZIs\ncc/k/0jWi88FBzy/qgnag9jSXkNTcD6IyxQCbuUBZOYkeKfRuUV8C76VioZg\nVkjownC492cdpXHiKMIPiIlQcINmGtZWKB/mt1AFy3UgXeTRDQ6agxG8F7np\nse0FpFEBLjB63SDxu+ZVYHKmC2kP9sf6u+ahBSz1os33TY6raFpSG6VwTVwm\nJhM1sukS3q9/FCVnOto9FuxWLb7iaeLx430dM+JSeuKczOa9t9k/ScRz7hds\n0dufDXCu/THnQFAKA3h9e5AfO89Pck6xtuEGht4Rn7gM4iIJ8mbNg6JGBMiw\nZlqtyqBdfT0+a+vekkLfbx+6boPCsahB4aYutIvTzq4Yhw2bNShb8NoNsdX9\nY+dhyoBtEfxMSUHnnEegJpOPegStg6F35pfJxe0s7L0mNmu8oD6ukY2k3Bec\nQ5/m1gIF0h2Qro15HJ/qtE/tg+ItEIMQHFJOhg9rDy9m+fIKKiSj5en7a+AK\n3hM1xs+q4sq28FA4VphivAsiQEgGMm5X5V3iqXF+5OZo6oX/fOdLuxhrjWlr\nZthb\r\n=wFk4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAg8mAcgS9B95oA/5JBCZVK7F+LxaKJURSzFrhHYenwOAiEA7QyM2ZYo//j0juFVrAeLe4AuowXQsBrOI6G7JCJRZy4="}]},"maintainers":[{"name":"bencuk","email":"benc.uk@gmail.com"}],"_npmUser":{"name":"bencuk","email":"benc.uk@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsonlint_0.0.0-development_1584265915603_0.3779644260972135"},"_hasShrinkwrap":false},"10.2.1-fork":{"name":"@bencuk/jsonlint","publishConfig":{"access":"public"},"version":"10.2.1-fork","description":"FORKED! JSON/CJSON/JSON5 parser, syntax and schema validator and pretty-printer.","author":{"name":"Ferdinand Prantl","email":"prantlf@gmail.com","url":"http://prantl.tk"},"contributors":[{"name":"Greg Inman","email":"ginman@itriagehealth.com"},{"name":"Paul Vollmer","email":"mail@paulvollmer.net","url":"http://paulvollmer.net"},{"name":"Zach Carter","email":"zach@carter.name","url":"http://zaa.ch"}],"license":"MIT","licenses":[{"type":"MIT","url":"https://github.com/prantlf/jsonlint/blob/master/LICENSE"}],"homepage":"http://prantlf.github.com/jsonlint/","repository":{"type":"git","url":"git+https://github.com/prantlf/jsonlint.git"},"bugs":{"url":"http://github.com/prantlf/jsonlint/issues"},"preferGlobal":true,"main":"lib/jsonlint.js","typings":"lib/jsonlint.d.ts","bin":{"jsonlint":"lib/cli.js"},"engines":{"node":">= 6"},"scripts":{"prepare":"npm run lint && npm run build","lint":"npm run lint:js && npm run lint:ts","lint:js":"standard --fix -v","lint:ts":"tslint --fix -t stylish lib/*.ts test/*.ts","build":"npm run compile && npm run compile:tests","compile":"node scripts/bundle-jsonlint && uglifyjs -o web/jsonlint.min.js --source-map \"filename='jsonlint.js',url='jsonlint.min.js.map',includeSources=true\" lib/jsonlint.js && uglifyjs -o web/validator.min.js --source-map \"filename='validator.js',url='validator.min.js.map',includeSources=true\" lib/validator.js && uglifyjs -o web/formatter.min.js --source-map \"filename='formatter.js',url='formatter.min.js.map',includeSources=true\" lib/formatter.js && uglifyjs -o web/sorter.min.js --source-map \"filename='sorter.js',url='sorter.min.js.map',includeSources=true\" lib/sorter.js && uglifyjs -o web/printer.min.js --source-map \"filename='printer.js',url='printer.min.js.map',includeSources=true\" lib/printer.js && node scripts/bundle-schema-drafts && uglifyjs -o web/schema-drafts.min.js --source-map \"filename='schema-drafts.js',url='schema-drafts.min.js.map',includeSources=true\" lib/schema-drafts.js && uglifyjs -o web/ajv.min.js --source-map \"filename='ajv.js',url='ajv.min.js.map',includeSources=true\" node_modules/ajv/dist/ajv.bundle.js","compile:tests":"tsc --lib es6 test/typings.test.ts","test":"nyc --silent node test/typings.test.js && nyc --silent --no-clean node test/parse1 && nyc --silent --no-clean node test/parse1 --native-parser && nyc --silent --no-clean node test/parse2 && nyc --silent --no-clean node test/parse3 && nyc --silent --no-clean node test/parse4 && nyc --silent --no-clean node test/parse5 && nyc --silent --no-clean node test/portable && nyc --silent --no-clean node test/tokenize && nyc --silent --no-clean node test/print && nyc --silent --no-clean node lib/cli package.json test/recursive && nyc --silent --no-clean node lib/cli -sq test/passes/hasOwnProperty.json && nyc --silent --no-clean node lib/cli -s -e json-schema-draft-04 -V test/passes/3.schema.json test/passes/3.json && nyc --silent --no-clean node lib/cli -C test/passes/comments.txt && nyc --silent --no-clean node lib/cli -pS test/passes/strings.txt && nyc --silent --no-clean node lib/cli -M json5 test/passes/json5.text && nyc --silent --no-clean node lib/cli -v && nyc --silent --no-clean node lib/cli -h && nyc --silent --no-clean node lib/cli -Pc test/fails/10.json || nyc report","start":"http-server -c 5","web":"npm run web:sync && npm run web:deploy","web:clone":"test ! -d ../jsonlint-pages && git clone --single-branch --branch gh-pages `git remote get-url origin` ../jsonlint-pages","web:pull":"cd ../jsonlint-pages && git pull","web:sync":"cp web/*.min.* ../jsonlint-pages/ && cp web/jsonlint.html ../jsonlint-pages/index.html","web:deploy":"cd ../jsonlint-pages && git commit -a -m 'Deploy site updates' && git push origin gh-pages"},"standard":{"ignore":["benchmarks/jison","benchmarks/pegjs","jsonlint*.js","test/fails","test/passes","test/recursive","test/v8"]},"keywords":["json","validation","lint","jsonlint"],"dependencies":{"ajv":"6.10.2","commander":"4.0.1"},"devDependencies":{"@types/node":"13.1.1","http-server":"0.12.0","js-yaml":"3.13.1","nyc":"15.0.0","standard":"14.3.1","test":"0.6.0","tslint":"5.20.1","tslint-config-standard":"9.0.0","typescript":"3.7.4","uglify-js":"3.7.3"},"gitHead":"a74ee2f42a87cfa60664e9dd17787d81abe25a82","_id":"@bencuk/jsonlint@10.2.1-fork","_nodeVersion":"12.16.1","_npmVersion":"6.13.1","dist":{"integrity":"sha512-onLafrMh9xCBjzEpHSaVwnIq/wmRzNSiEmT+hV2c37deQWF5YCVbu/iuMqOuTA+3F9cXIJFlhyRze2xOyVSvtg==","shasum":"ca6d94175289d0f1d278734788d4fb5428f2815c","tarball":"https://registry.npmjs.org/@bencuk/jsonlint/-/jsonlint-10.2.1-fork.tgz","fileCount":28,"unpackedSize":890471,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebfstCRA9TVsSAnZWagAADL0QAKQbXovt1CyAzbH8vViE\neinQCB4/w5zpobJpBHH1GH/Z72uUFz9H0nq8VPjGO90mYjnnWdQpivxfKQef\nT2wk69kQtEaBNXJdzmptl0C8JXmeShXw2KVetnO14wUNmxRLebrrf0xY6/w1\nc6YRalk6SLxjfHgs0y7mQ5xY2uCmIORmVNk0yt3ddKjYLBUyEchLwwsa6QSM\ncKjc0MJSJs/54iaKaKohOps19rKtSLNB6WSrIR75PehYyrnJIfQ3nE7c9lbr\nm1kaHFNkeKS/WSOhkNs/8CJyMjF3jFDLzREc9UE+gX/yDRRhu9l+q2Gj8msC\ncSdJ/P8ydXCPV5zeShC2esX9QvVE4CguoQsVZzdY/rhnSp2DXaYY0jdC6FKa\nCTCQBCZD847PR0a8iyyx4DbmPQtBn0A6qDmaQe7EC5gHxK8h0n6hWPyK0KKV\nzmOx6AycWD0x92tfzfmCMwgRwoe2GlOuK1+7/iUC/mLr3JPUlz8leVt7yul1\n7oaWBAvOf/E9PH4TvaBOUygju/w5XMJoEHJ3DBcjZ/l1ZazcVy2XSl6fW/An\n1tUJ6XNIlCehBVYyV/iPwdgpY6jX3pRR+bKM/f7k6OcEOl5SMMOEDMGpNhuN\nVpur1cDiMdseToQBC6RDII8IEldfxUPXTqWEoQ8kPMC/0YcTwCSk3RK80XY/\ngh2p\r\n=+buB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDk68iNQQtFm0dfvlx057jtuH5f1uNWPPXYwtuClgXVYQIhALCU4QgdTS9Zr20mb5vjE2Qp/7JsKInlx/HIjYR1ltTG"}]},"maintainers":[{"name":"bencuk","email":"benc.uk@gmail.com"}],"_npmUser":{"name":"bencuk","email":"benc.uk@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsonlint_10.2.1-fork_1584266028450_0.43627105199058636"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-15T09:51:55.368Z","0.0.0-development":"2020-03-15T09:51:55.785Z","modified":"2022-04-04T18:22:00.426Z","10.2.1-fork":"2020-03-15T09:53:48.631Z"},"maintainers":[{"name":"bencuk","email":"benc.uk@gmail.com"}],"description":"FORKED! JSON/CJSON/JSON5 parser, syntax and schema validator and pretty-printer.","homepage":"http://prantlf.github.com/jsonlint/","keywords":["json","validation","lint","jsonlint"],"repository":{"type":"git","url":"git+https://github.com/prantlf/jsonlint.git"},"contributors":[{"name":"Greg Inman","email":"ginman@itriagehealth.com"},{"name":"Paul Vollmer","email":"mail@paulvollmer.net","url":"http://paulvollmer.net"},{"name":"Zach Carter","email":"zach@carter.name","url":"http://zaa.ch"}],"author":{"name":"Ferdinand Prantl","email":"prantlf@gmail.com","url":"http://prantl.tk"},"bugs":{"url":"http://github.com/prantlf/jsonlint/issues"},"license":"MIT","readme":"# JSON Lint\n\n[![NPM version](https://badge.fury.io/js/%40prantlf%2Fjsonlint.svg)](https://badge.fury.io/js/%40prantlf%2Fjsonlint)\n[![Build Status](https://travis-ci.com/prantlf/jsonlint.svg?branch=master)](https://travis-ci.com/prantlf/jsonlint)\n[![codecov](https://codecov.io/gh/prantlf/jsonlint/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/jsonlint)\n[![Dependency Status](https://david-dm.org/prantlf/jsonlint.svg)](https://david-dm.org/prantlf/jsonlint)\n[![devDependency Status](https://david-dm.org/prantlf/jsonlint/dev-status.svg)](https://david-dm.org/prantlf/jsonlint#info=devDependencies)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\nA [JSON]/CJSON/[JSON5] parser, validator and pretty-printer with a command-line client. A [pure JavaScript version] of the service provided at [jsonlint.com].\n\nThis is a fork of the original package with the following enhancements:\n\n* Handles multiple files on the command line (by Greg Inman).\n* Walks directories recursively (by Paul Vollmer).\n* Provides 100% compatible interface to the native `JSON.parse` method.\n* Optionally recognizes JavaScript-style comments (CJSON) and single quoted strings (JSON5).\n* Optionally ignores trailing commas and reports duplicate object keys as an error.\n* Supports [JSON Schema] drafts 04, 06 and 07.\n* Offers pretty-printing including comment-stripping and object keys without quotes (JSON5).\n* Prefers the native JSON parser if possible to run [7x faster than the custom parser].\n* Reports errors with rich additional information. From the schema validation too.\n* Implements JavaScript modules using [UMD] to work everywhere.\n* Depends on up-to-date npm modules with no installation warnings.\n* Small size - 18.2 kB minified, 6.3 kB gzipped.\n\n**Note:** In comparison with the original project, this package exports only the `parse` method; not the `Parser` object.\n\nIntegration to the favourite task loaders for JSON file validation is provided by the following NPM modules:\n\n* [`Grunt`] - see [`@prantlf/grunt-jsonlint`]\n* [`Gulp`] - see [`@prantlf/gulp-jsonlint`]\n* [`Rollup`] - see [`rollup-plugin-jsonlint`]\n\n## Synopsis\n\nCheck syntax of JSON files:\n\n    jsonlint -q data/*.json\n\nParse a JSON string:\n\n```js\nconst { parse } = require('@prantlf/jsonlint')\nconst data = parse('{\"creative\": false}')\n```\n\nExample of an error message:\n\n    Parse error on line 1, column 14:\n    {\"creative\": ?}\n    -------------^\n    Unexpected token \"?\"\n\n## Command-line Interface\n\nInstall `jsonlint` with `npm`` globally to be able to use the command-line interface in any directory:\n\n    npm i @prantlf/jsonlint -g\n\nValidate a single file:\n\n    jsonlint myfile.json\n\nor pipe the JSON input into `stdin`:\n\n    cat myfile.json | jsonlint\n\nor process all `.json` files in a directory:\n\n    jsonlint mydir\n\nBy default, `jsonlint` will either report a syntax error with details or pretty-print the source if it is valid.\n\n### Options\n\n    $ jsonlint -h\n\n    Usage: jsonlint [options] [<file or directory> ...]\n\n    JSON parser, syntax and schema validator and pretty-printer.\n\n    Options:\n      -s, --sort-keys              sort object keys (not when prettifying)\n      -E, --extensions [ext]       file extensions to process for directory walk\n                                   (default: [\"json\",\"JSON\"])\n      -i, --in-place               overwrite the input files\n      -t, --indent [num|char]      number of spaces or specific characters\n                                   to use for indentation (default: 2)\n      -c, --compact                compact error display\n      -M, --mode [mode]            set other parsing flags according to a format\n                                   type (default: \"json\")\n      -C, --comments               recognize and ignore JavaScript-style comments\n      -S, --single-quoted-strings  support single quotes as string delimiters\n      -T, --trailing-commas        ignore trailing commas in objects and arrays\n      -D, --no-duplicate-keys      report duplicate object keys as an error\n      -V, --validate [file]        JSON schema file to use for validation\n      -e, --environment [env]      which specification of JSON Schema the\n                                   validation file uses\n      -q, --quiet                  do not print the parsed json to stdin\n      -p, --pretty-print           prettify the input instead of stringifying\n                                   the parsed object\n      -P, --pretty-print-invalid   force pretty-printing even for invalid input\n      --prune-comments             omit comments from the prettified output\n      --strip-object-keys          strip quotes from object keys if possible\n                                   (JSON5)\n      --enforce-double-quotes      surrounds all strings with double quotes\n      --enforce-single-quotes      surrounds all strings with single quotes\n                                   (JSON5)\n      --trim-trailing-commas       omit trailing commas from objects and arrays\n                                   (JSON5)\n      -v, --version                output the version number\n      -h, --help                   output usage information\n\n    Parsing mode can be \"cjson\" or \"json5\" to enable other flags automatically.\n    If no files or directories are specified, stdin will be parsed. Environments\n    for JSON schema validation are \"json-schema-draft-04\", \"json-schema-draft-06\"\n    or \"json-schema-draft-07\". If not specified, it will be auto-detected.\n\n## Module Interface\n\nInstall `jsonlint` with `npm` locally to be able to use the module programmatically:\n\n    npm i @prantlf/jsonlint -S\n\nThe only exported item is the `parse` method, which parses a string in the JSON format to a JavaScript object, array, or value:\n\n```js\nconst { parse } = require('@prantlf/jsonlint')\n// Fails at the position of the character \"?\".\nconst data2 = parse('{\"creative\": ?}') // throws an error\n// Succeeds returning the parsed JSON object.\nconst data3 = parse('{\"creative\": false}')\n// Recognizes comments and single-quoted strings.\nconst data3 = parse(\"{'creative': true /* for creativity */}\", {\n  ignoreComments: true,\n  allowSingleQuotedStrings: true\n})\n```\n\nHave a look at the [source] of the [on-line page] to see how to use `jsonlint` on web page.\n\nThe exported `parse` method is compatible with the native `JSON.parse` method. The second parameter provides the additional functionality:\n\n    parse(input, [reviver|options])\n\n| Parameter  | Description                                 |\n| ---------- | ------------------------------------------- |\n| `input`    | text in the JSON format (string)            |\n| `reviver`  | converts object and array values (function) |\n| `options`  | customize parsing options (object)          |\n\nThe `parse` method offers more detailed [error information](#error-handling), than the native `JSON.parse` method and it supports additional parsing options:\n\n| Option                     | Description                                 |\n| -------------------------- | ------------------------------------------- |\n| `ignoreComments`           | ignores single-line and multi-line JavaScript-style comments during parsing as another \"whitespace\" (boolean) |\n| `ignoreTrailingCommas`     | ignores trailing commas in objects and arrays (boolean)      |\n| `allowSingleQuotedStrings` | accepts strings delimited by single-quotes too (boolean)     |\n| `allowDuplicateObjectKeys` | allows reporting duplicate object keys as an error (boolean) |\n| `mode`                     | sets multiple options according to the type of input data (string) |\n| `reviver`                  | converts object and array values (function) |\n\nThe `mode` parameter (string) sets parsing options to match a common format of input data:\n\n| Mode    | Description                                               |\n| ------- | --------------------------------------------------------- |\n| `json`  | complies to the pure standard [JSON] (default if not set) |\n| `cjson` | JSON with comments (sets `ignoreComments`)                |\n| `json5` | complies to [JSON5]  (sets `ignoreComments`, `allowSingleQuotedStrings`, `ignoreTrailingCommas` and enables other JSON5 features) |\n\n### Schema Validation\n\nYou can validate the input against a JSON schema using the `lib/validator` module. The `validate` method accepts either an earlier parsed JSON data or a string with the JSON input:\n\n```js\nconst { compile } = require('@prantlf/jsonlint/lib/validator')\nconst validate = compile('string with JSON schema')\n// Throws an error in case of failure.\nconst parsed = validate('string with JSON data')\n```\n\nIf a string is passed to the `validate` method, the same options as for parsing JSON data can be passed as the second parameter. Compiling JSON schema supports the same options as parsing JSON data too (except for `reviver`). They can be passed as the second (object) parameter. The optional second `environment` parameter can be passed either as a string or as an additional property in the options object too:\n\n```js\nconst validate = compile('string with JSON schema', {\n  environment: 'json-schema-draft-04'\n})\n```\n\n### Pretty-Printing\n\nYou can parse a JSON string to an array of tokens and print it back to a string with some changes applied. It can be unification of whitespace, reformatting or stripping comments, for example. (Raw token values must be enabled when tokenizing the JSON input.)\n\n```js\nconst { tokenize } = require('@prantlf/jsonlint')\nconst tokens = tokenize('string with JSON data', { rawTokens: true })\nconst { print } = require('@prantlf/jsonlint/lib/printer')\nconst output = print(tokens, { indent: 2 })\n```\n\nThe [`tokenize`](#tokenizing) method accepts options in the second optional parameter. See the [`tokenize`](#tokenizing) method above for more information.\n\nThe [`print`](#pretty-printing) method accepts an object `options` as the second optional parameter. The following properties will be recognized there:\n\n| Option                      | Description                                             |\n| --------------------------- | ------------------------------------------------------- |\n| `indent`                    | count of spaces or the specific characters to be used as an indentation unit |\n| `pruneComments`             | will omit all tokens with comments                      |\n| `stripObjectKeys`           | will not print quotes around object keys which are JavaScript identifier names |\n| `enforceDoubleQuotes`       | will surround all strings with double quotes            |\n| `enforceSingleQuotes`       | will surround all strings with single quotes            |\n| `trimTrailingCommas`        | will omit all trailing commas after the last object entry or array item |\n\n```js\n// Just concatenate the tokens to produce the same output as was the input.\nprint(tokens)\n// Strip all whitespace. (Just like `JSON.stringify(json)` would do it,\n// but leaving comments in the output.)\nprint(tokens, {})\n// Print to multiple lines without object and array indentation.\n// (Just introduce line breaks.)\nprint(tokens, { indent: '' })\n// Print to multiple lines with object and array indentation. (Just like\n//`JSON.stringify(json, undefined, 2)` would do it, but retaining comments.)\nprint(tokens, { indent: 2 })\n// Print to multiple lines with object and array indentation, omit comments.\n// (Just like `JSON.stringify(json, undefined, '  ')` would do it.)\nprint(tokens, { indent: '  ', pruneComments: true })\n// Print to multiple lines with indentation enabled and JSON5 object keys.\nprint(tokens, { indent: '\\t', stripObjectKeys: true })\n// Print to multiple lines with indentation enabled, unify JSON5 formatting.\nprint(tokens, {\n  indent: '    ',\n  enforceDoubleQuotes: true,\n  trimTrailingCommas: true\n})\n```\n\n### Tokenizing\n\nThe method `tokenize` has the same prototype as the method [`parse`](#module-interface), but returns an array of tokens instead of the JSON object.\n\n```js\nconst { tokenize } = require('@prantlf/jsonlint')\nconst tokens = tokenize('{\"flag\":true /* default */}', {\n  ignoreComments: true,\n  rawTokens: true\n}))\n// Returns the following array:\n// [\n//   { type: 'symbol',     raw: '{',      value: '{' },\n//   { type: 'literal',    raw: '\"flag\"', value: 'flag' },\n//   { type: 'symbol',     raw: ':',      value: ':' },\n//   { type: 'literal',    raw: 'true',   value: true },\n//   { type: 'whitespace', raw: ' ' },\n//   { type: 'comment',    raw: '/* default */' },\n//   { type: 'symbol',     raw: '}',      value: '}' }\n// ]\n```\n\nThe `tokenize` method accepts options in the second optional parameter. See the [`parse`](#module-interface) method above for the shared options. There are several additional options supported for the tokenization:\n\n| Option           | Description                                                        |\n| -----------------| ------------------------------------------------------------------ |\n| `rawTokens`      | adds a `raw` property with the original string from the JSON input |\n| `tokenLocations` | adds a `location` property with start, end and length of the original string from the JSON input |\n| `tokenPaths`     | adds a `path` property with an array of keys and array indexes \"on the way to\" the token's value |\n\nIf you want to retain comments or whitespace for pretty-printing, for example, set `rawTokens` to true. (The [`print`](#pretty-printing) method requires tokens produced with this flag enabled.)\n\n### Performance\n\nThis is a part of an output from the [parser benchmark], when parsing a 4.2 KB formatted string ([package.json](./package.json)) with Node.js 12.14.0:\n\n    jsonlint using native JSON.parse x 97,109 ops/sec ±0.81% (93 runs sampled)\n    jsonlint using hand-coded parser x 7,256 ops/sec ±0.54% (90 runs sampled)\n    jsonlint using tokenising parser x 6,387 ops/sec ±0.44% (88 runs sampled)\n\nA custom JSON parser is [a lot slower] than the built-in one. However, it is more important to have a [clear error reporting] than the highest speed in scenarios like parsing configuration files. (For better error-reporting, the speed can be preserved by using the native parser initially and re-parsing with another parser only in case of failure.) Features like comments or JSON5 are also helpful in configuration files. Tokens preserve the complete input and can be used for pretty-printing without losing the comments.\n\n### Error Handling\n\nIf parsing fails, a `SyntaxError` will be thrown with the following properties:\n\n| Property   | Description                               |\n| ---------- | ----------------------------------------- |\n| `message`  | the full multi-line error message         |\n| `reason`   | one-line explanation of the error         |\n| `excerpt`  | part of the input string around the error |\n| `pointer`  | \"--^\" pointing to the error in `excerpt`  |\n| `location` | object pointing to the error location     |\n\nThe `location` object contains properties `line`, `column` and `offset`.\n\nThe following code logs twice the following message:\n\n    Parse error on line 1, column 14:\n    {\"creative\": ?}\n    -------------^\n    Unexpected token \"?\"\n\n```js\nconst { parse } = require('@prantlf/jsonlint')\ntry {\n  parse('{\"creative\": ?}')\n} catch (error) {\n  const { message, reason, excerpt, pointer, location } = error\n  const { column, line, offset } = location.start\n  // Logs the complete error message:\n  console.log(message)\n  // Logs the same text as included in the `message` property:\n  console.log(`Parse error on line ${line}, ${column} column:\n${excerpt}\n${pointer}\n${reason}`)\n}\n```\n\n## License\n\nCopyright (C) 2012-2019 Zachary Carter, Ferdinand Prantl\n\nLicensed under the [MIT License].\n\n[MIT License]: http://en.wikipedia.org/wiki/MIT_License\n[pure JavaScript version]: http://prantlf.github.com/jsonlint/\n[jsonlint.com]: http://jsonlint.com\n[JSON]: https://tools.ietf.org/html/rfc8259\n[JSON5]: https://spec.json5.org\n[JSON Schema]: https://json-schema.org\n[UMD]: https://github.com/umdjs/umd\n[`Grunt`]: https://gruntjs.com/\n[`Gulp`]: http://gulpjs.com/\n[`Rollup`]: https://rollupjs.org/\n[`@prantlf/grunt-jsonlint`]: https://www.npmjs.com/package/@prantlf/grunt-jsonlint\n[`@prantlf/gulp-jsonlint`]: https://www.npmjs.com/package/@prantlf/gulp-jsonlint\n[`rollup-plugin-jsonlint`]: https://www.npmjs.com/package/rollup-plugin-jsonlint\n[7x faster than the custom parser]: ./benchmarks/results/performance.md#results\n[parser benchmark]: ./benchmarks#json-parser-comparison\n[a lot slower]: ./benchmarks/results/performance.md#results\n[clear error reporting]: ./benchmarks/results/errorReportingQuality.md#results\n[on-line page]: http://prantlf.github.com/jsonlint/\n[source]: ./web/jsonlint.html\n","readmeFilename":"README.md"}