Socket
Socket
Sign inDemoInstall

parse-json

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-json - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

22

index.js
'use strict';
var errorEx = require('error-ex');
var fallback = require('./vendor/parse');
var JSONError = errorEx('JSONError', {
fileName: errorEx.append('in %s')
});
module.exports = function (x, reviver) {
try {
return JSON.parse(x, reviver);
try {
return JSON.parse(x, reviver);
} catch (err) {
fallback.parse(x, {
mode: 'json',
reviver: reviver
});
throw err;
}
} catch (err) {
fallback.parse(x, {
mode: 'json',
reviver: reviver
});
JSONError.call(err);
throw err;
}
};
{
"name": "parse-json",
"version": "2.0.0",
"version": "2.1.0",
"description": "Parse JSON with more helpful errors",

@@ -34,2 +34,5 @@ "license": "MIT",

],
"dependencies": {
"error-ex": "^1.1.0"
},
"devDependencies": {

@@ -36,0 +39,0 @@ "ava": "0.0.4",

@@ -29,6 +29,19 @@ # parse-json [![Build Status](https://travis-ci.org/sindresorhus/parse-json.svg?branch=master)](https://travis-ci.org/sindresorhus/parse-json)

/*
SyntaxError: Trailing comma in object at 3:1
JSONError: Trailing comma in object at 3:1
}
^
*/
try {
parseJson(json);
} catch (err) {
err.fileName = 'foo.json';
throw err;
}
/*
JSONError: Trailing comma in object at 3:1 in foo.json
}
^
*/
```

@@ -35,0 +48,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc