Socket
Socket
Sign inDemoInstall

is-json

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-json - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

6

index.js

@@ -18,2 +18,4 @@ function isString (x) {

str = str.replace(/\s/g, '').replace(/\n|\r/, '');
if (/^\{(.*?)\}$/.test(str))

@@ -23,8 +25,6 @@ return /"(.*?)":(.*?)/g.test(str);

if (/\[(.*?)\]/.test(str)) {
str = str.replace(/\s/g, '')
.replace(/^\[/, '')
str = str.replace(/^\[/, '')
.replace(/\]$/, '')
.replace(/},{/g, '}\n{')
.split(/\n/);
console.log(str);
return str.map(function (s) { return isJSON(s); })

@@ -31,0 +31,0 @@ .reduce(function (prev, curr) { return !!curr; });

{
"name": "is-json",
"version": "1.1.4",
"version": "1.1.5",
"description": "check if a string is a valid JSON string without using Try/Catch",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,3 +6,3 @@ var test = require('tape');

test('performe isJSON verifications', function (t) {
t.plan(14);
t.plan(15);

@@ -24,4 +24,5 @@ t.deepEqual(isJSON(null), false, '`null`, should return false');

t.deepEqual(isJSON('[{"a": 123}, {1,2,3}}]'), false, '`[{"a": 123, {1,2,3}}]`, should return false');
t.deepEqual(isJSON('[{"a": {"aa": [1,2,3,4], "aaa": {"d": 1212}}}, {"b": "test", "c": [1,2,3]}]'),
true, 'complex object should return true');
var cobj = '[{"a": {"aa": [1,2,3,4], "aaa": {"d": 1212}}}, {"b": "test", "c": [1,2,3], "date": "' + new Date() + '"}]';
t.deepEqual(isJSON(cobj), true, cobj + ', should return true');
t.deepEqual(isJSON(new Date()), false, '`Date`, should return false');
});
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc