Comparing version 1.1.4 to 1.1.5
@@ -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'); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5054