https://github.com/postmanlabs/liquid-json
Implementation of JSON that ignores BOM and thows friendly error
https://github.com/postmanlabs/liquid-json
Last synced: 3 months ago
JSON representation
Implementation of JSON that ignores BOM and thows friendly error
- Host: GitHub
- URL: https://github.com/postmanlabs/liquid-json
- Owner: postmanlabs
- License: apache-2.0
- Created: 2016-08-24T19:28:37.000Z (over 9 years ago)
- Default Branch: develop
- Last Pushed: 2023-06-22T14:49:46.000Z (over 2 years ago)
- Last Synced: 2025-01-30T07:11:12.969Z (12 months ago)
- Language: JavaScript
- Size: 1.85 MB
- Stars: 6
- Watchers: 17
- Forks: 7
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.yaml
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# liquid-json
Implementation of `JSON` which ignores BOM and shows more detailed error messages on parse failures.
## usage
```terminal
$ npm install liquid-json --save;
```
```javascript
var LJSON = require('liquid-json');
LJSON.parse('{ "hello": "world" }');
LJSON.stringify({ hello: 'world' });
```
`LJSON.parse` accepts `reviver` function as second parameter and `LJSON.stringify` accepts standard JSON parameters.
All errors raised from this module has error name as `JSONError`.
### asynchronous flavour
```javascript
var LJSON = require('liquid-json').async;
LJSON.parse('{ "hello": "world" }', function (err, obj) {
console.log(obj); // logs the object
});
LJSON.stringify({ hello: 'world' }, function (err, text) {
console.log(text); // logs '{"hello":"world"}'
});
```
## attributions
- https://github.com/rlidwka/jju
- https://github.com/ariya/esprima