{"name":"parse-json","version":"8.3.0","description":"Parse JSON with more helpful errors","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/parse-json.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && c8 ava && tsd"},"keywords":["parse","json","graceful","error","message","humanize","friendly","helpful","string"],"dependencies":{"@babel/code-frame":"^7.26.2","index-to-position":"^1.1.0","type-fest":"^4.39.1"},"devDependencies":{"ava":"^6.2.0","c8":"^10.1.3","outdent":"^0.8.0","strip-ansi":"^7.1.0","tsd":"^0.31.2","xo":"^0.60.0"},"_id":"parse-json@8.3.0","gitHead":"6fee59751db59a539fdf53537101a1d7c6378a65","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/parse-json/issues"},"homepage":"https://github.com/sindresorhus/parse-json#readme","_nodeVersion":"23.6.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-ybiGyvspI+fAoRQbIPRddCcSTV9/LsJbf0e/S85VLowVGzRmokfneg2kwVW/KU5rOXrPSbF1qAKPMgNTqqROQQ==","shasum":"88a195a2157025139a2317a4f2f9252b61304ed5","tarball":"http://registry-npm.ywwl.com/parse-json/download/parse-json-8.3.0.tgz","fileCount":5,"unpackedSize":10975,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC+Ca34Dlc/v6P2mtwoiQmrNw1TpX/lovEleCDHKxr92QIgK2lF7ou/TW3kT9r4bGxtBX3ywNYRcrZL8uh/aQKreWc="}],"size":3456,"noattachment":false,"key":"/parse-json/-/parse-json-8.3.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/parse-json_8.3.0_1744189323129_0.7474471720361489"},"_hasShrinkwrap":false,"readme":"# parse-json\n\n> Parse JSON with more helpful errors\n\n## Install\n\n```sh\nnpm install parse-json\n```\n\n## Usage\n\n```js\nimport parseJson, {JSONError} from 'parse-json';\n\nconst json = '{\\n\\t\"foo\": true,\\n}';\n\n\nJSON.parse(json);\n/*\nSyntaxError: Expected double-quoted property name in JSON at position 16 (line 3 column 1)\n*/\n\n\nparseJson(json);\n/*\nJSONError: Expected double-quoted property name in JSON at position 16 (line 3 column 1)\n\n  1 | {\n  2 |   \"foo\": true,\n> 3 | }\n    | ^\n*/\n\n\nparseJson(json, 'foo.json');\n/*\nJSONError: Expected double-quoted property name in JSON at position 16 (line 3 column 1) in foo.json\n\n  1 | {\n  2 |   \"foo\": true,\n> 3 | }\n    | ^\n  fileName: 'foo.json',\n  [cause]: SyntaxError: Expected double-quoted property name in JSON at position 16 (line 3 column 1)\n      at JSON.parse (<anonymous>)\n      at ...\n*/\n\n\n// You can also add the filename at a later point\ntry {\n\tparseJson(json);\n} catch (error) {\n\tif (error instanceof JSONError) {\n\t\terror.fileName = 'foo.json';\n\t}\n\n\tthrow error;\n}\n/*\nJSONError: Expected double-quoted property name in JSON at position 16 (line 3 column 1) in foo.json\n\n  1 | {\n  2 |   \"foo\": true,\n> 3 | }\n    | ^\n\n  fileName: 'foo.json',\n  [cause]: SyntaxError: Expected double-quoted property name in JSON at position 16 (line 3 column 1)\n      at JSON.parse (<anonymous>)\n      at ...\n*/\n```\n\n## API\n\n### parseJson(string, reviver?, filename?)\n\nThrows a `JSONError` when there is a parsing error.\n\n#### string\n\nType: `string`\n\n#### reviver\n\nType: `Function`\n\nPrescribes how the value originally produced by parsing is transformed, before being returned. See [`JSON.parse` docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter\n) for more.\n\n#### filename\n\nType: `string`\n\nThe filename displayed in the error message.\n\n### JSONError\n\nExposed for `instanceof` checking.\n\n#### fileName\n\nType: `string`\n\nThe filename displayed in the error message.\n\n#### codeFrame\n\nType: `string`\n\nThe printable section of the JSON which produces the error.\n\n#### rawCodeFrame\n\nType: `string`\n\nThe raw version of `codeFrame` without colors.\n","publish_time":1744189323317,"_cnpm_publish_time":1744189323317,"dist-tags":{"latest":"8.3.0"}}