jp2p
v1.0.1
Published
A utility method to get the line to which a JSON pointer points in a given JSON string.
Downloads
44
Readme
jp2p (JSON pointer to position)
A utility method to get the line & column to which a JSON pointer points in a given JSON string.
More information about JSON pointers in the RFC6901;
How to use
The module only contains one method, use it like this:
const { getLineNumber } = require('jp2p');
const jsonString = '{\n "toto": "tata"\n}';
console.log(getLineNumber(jsonString, '/toto'));
In this case it will output { line: 2, column: 10 }
. The line in the jsonString at which the element at JSON pointer /toto
is defined.
Contributing
You think it lacks a feature ? Spot a bug ? Insufficient documentation ? Any contribution is welcome, below are a few contribution guidelines but first get a look at these general guidelines:
- Git
- Fork the plugin repository.
- Hack on a separate topic branch created from the latest
master
. - Commit and push the topic branch.
- Make a pull request.
- Tests
- You can run tests with
npm test
- All tests should pass on any pull request
- Please add a test for non-regression on your dev
- You can run tests with
- Other
- Code should pass linting by eslint (run
npm run lint
to test this). - Let me know by mail before contributing (don't want to waste your time on something already being done)
- You don't know how or don't have the time to contribute ? Don't hesitate to share your ideas in issues
- Code should pass linting by eslint (run
Thank you for helping out!