relaxed-json
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "relaxed-json", | ||
"description": "Relaxed JSON is strict superset JSON, relaxing strictness of valilla JSON", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"homepage": "https://github.com/phadej/relaxed-json", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -39,2 +39,5 @@ # Relaxed JSON | ||
- 0.2.3 Bugfixes | ||
- `$` is valid identifier character | ||
- single line comments may end with `CR` and `CRLF` also | ||
- 0.2.2 Bugfix | ||
@@ -41,0 +44,0 @@ - 0.2.1 Code reogranization |
@@ -176,5 +176,5 @@ /* | ||
{ re: /^'(([^'\\]|\\['bnrtf\\]|\\u[0-9a-fA-F]{4})*)'/, f: fStringSingle }, | ||
{ re: /^\/\/.*?\n/, f: fComment }, | ||
{ re: /^\/\/.*?(?:\r\n|\r|\n)/, f: fComment }, | ||
{ re: /^\/\*[\s\S]*?\*\//, f: fComment }, | ||
{ re: /^[a-zA-Z0-9_\-+\.\*\?!\|&%\^\/#\\]+/, f: fIdentifier }, | ||
{ re: /^[$a-zA-Z0-9_\-+\.\*\?!\|&%\^\/#\\]+/, f: fIdentifier }, | ||
]); | ||
@@ -541,2 +541,24 @@ } | ||
function stringifyPair(obj, key) { | ||
return JSON.stringify(key) + ":" + stringify(obj[key]); | ||
} | ||
function stringify(obj) { | ||
switch (typeof obj) { | ||
case "string": | ||
case "number": | ||
case "boolean": | ||
return JSON.stringify(obj); | ||
} | ||
if (Array.isArray(obj)) { | ||
return "[" + obj.map(stringify).join(",") + "]"; | ||
} | ||
if (new Object(obj) === obj) { | ||
var keys = Object.keys(obj); | ||
keys.sort(); | ||
return "{" + keys.map(stringifyPair.bind(null, obj)) + "}"; | ||
} | ||
return "null"; | ||
} | ||
// Export stuff | ||
@@ -546,2 +568,3 @@ var RJSON = { | ||
parse: parse, | ||
stringify: stringify, | ||
}; | ||
@@ -548,0 +571,0 @@ |
@@ -393,1 +393,12 @@ /* global describe, it */ | ||
}); | ||
describe("stringify", function () { | ||
it("works", function () { | ||
var property = jsc.forall(jsc.value(), function (x) { | ||
var y = JSON.parse(rjson.stringify(x)); | ||
return _.isEqual(x, y); | ||
}); | ||
jsc.assert(property, jscOpts); | ||
}); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
48100
923
53
0