- Notifications
You must be signed in to change notification settings - Fork3
✨ Add the context of a json parse error to the error message with syntax highlighting if possible.
License
americanexpress/json-parse-context
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Add the context of a json parse error to the error message with syntax highlighting if possible.
constjsonParseContext=require('json-parse-context');jsonParseContext(`{ "going": "to" "fail" true}`);
jsonParseContext(serialized [, reviver [, options]])
serialized(String):serialized JSONreviver(Function):prescribes how the value originally produced by parsing is transformedoptions(Object)lineCount(Number) [default:2]: lines of context to add above and below the line with a syntax error
In the project directory, you can run:
npm run test:git-history
Validates commit messages usingcommitlint
npm run test:lint
Verifies that your code matches the American Express code style defined ineslint-config-amex.
npm run test:lockfile
Validatespackage-lock.json with`lockfile-lint
npm run test:unit
Runs the unit tests usingjest with the presets defined inamex-jest-preset.
npm test
Runs all of the abovetest:* commands
These commands will be automatically run during normal git operations like committing code.
pre-commit
This hook runsnpm test before allowing a commit to be checked in.
commit-msg
This hook verifies that your commit message matches the One Amex conventions. See thecommitmessage section in thecontribution guidelines.
This package has been updated to be compatible with Node 20 and Node 22, however since the JSON error messages changed in these versions, automated testing for these versions is not possible.
When Node 18 is EOL, test targets for 20 and 22 will be added.
Any contributions made under this project will be governed by theApache License 2.0.
This project adheres to theAmerican Express Community Guidelines.By participating, you are expected to honor these guidelines.
About
✨ Add the context of a json parse error to the error message with syntax highlighting if possible.
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors14
Uh oh!
There was an error while loading.Please reload this page.

