Comparing version 0.1.2 to 0.1.3
@@ -56,7 +56,9 @@ /** | ||
mapp = [specialChar], | ||
isObject = (typeof value === 'object'), | ||
i | ||
; | ||
return function(key, value) { | ||
var valType = typeof value; | ||
var valType; | ||
@@ -69,4 +71,6 @@ // the replacer has rights to decide | ||
valType = typeof value | ||
// did you know ? Safari passes keys as integers for arrays | ||
if (key !== '') { | ||
if (key !== '' || !isObject) { | ||
@@ -91,3 +95,3 @@ if (valType === 'object' && value) { | ||
path.pop(); | ||
if (typeof value === 'string') { | ||
if (valType === 'string') { | ||
// ensure no special char involved on deserialization | ||
@@ -98,2 +102,12 @@ // in this case only first char is important | ||
.replace(specialChar, safeSpecialChar); | ||
} else if (valType === 'number') { | ||
// Allow infinite values | ||
if (!isFinite(value)) { | ||
if (value > 0) { | ||
value = {dry: '+Infinity'}; | ||
} else { | ||
value = {dry: '-Infinity'}; | ||
} | ||
} | ||
} | ||
@@ -125,5 +139,9 @@ } | ||
} | ||
} else if (valType == 'object') { | ||
} else if (value && valType == 'object' && typeof value.dry !== 'undefined') { | ||
if (value.dry == 'regexp' && value.value) { | ||
return RegExp.apply(undefined, getregex.exec(value.value).slice(1)); | ||
} else if (value.dry == '+Infinity') { | ||
return Infinity; | ||
} else if (value.dry == '-Infinity') { | ||
return -Infinity; | ||
} | ||
@@ -130,0 +148,0 @@ } |
{ | ||
"name": "json-dry", | ||
"description": "JSON generator & parser with circular, date and regex support", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Jelle De Loecker <jelle@codedor.be>", | ||
@@ -6,0 +6,0 @@ "keywords": ["json", "circular", "serialization", "deserialization"], |
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
7312
187