|
sfcode
An Online Competing and Development Environment
|
This release includes a bug fix and minor change.
parse throws on unclosed objects and arrays.package.json5 has been removed until an easier way to keep it in sync with package.json is found.This release includes major internal changes and public API enhancements.
stringify outputs trailing commas in objects and arrays when a space option is provided. (#66)stringify accepts an options object as its second argument. The supported options are replacer, space, and a new quote option that specifies the quote character used in strings. (#71)--out-file, --space, and --validate options. See json5 --help for more information. (#72, #84, and #108)\t, \v, \f, \n, \r, and \xA0, the additional white space characters \u2028, \u2029, and all other characters in the Space Separator Unicode category are allowed.,",\`, \b, \f, \n, \r, and \t, the additional character escapes \v and \0, hexadecimal escapes like \x0F, and unnecessary escapes like \a are allowed in string values and string property names.stringify outputs strings with single quotes by default but intelligently uses double quotes if there are more single quotes than double quotes inside the string. (i.e. ‘stringify('Stay here.’)outputs 'Stay here.'whilestringify('Let\'s go.')outputs"Let's go."`)stringify outputs a character escape like \t when available, a hexadecimal escape like \x0F when the Unicode code point is less than 256, or a Unicode character escape like \u01FF, in that order.stringify checks for a toJSON5 method on objects and, if it exists, stringifies its return value instead of the object. toJSON5 overrides toJSON if they both exist.require or import JSON5 files, use ‘require('json5/lib/register’) orimport 'json5/lib/register'. Previous versions usedjson5/lib/require`, which still exists for backward compatibility but is deprecated and will give a warning.dist/index.js or https://unpkg.com/json5@^1.0.0.stringify properly outputs Infinity and NaN. (#67)isWord no longer becomes a property of JSON5 after calling stringify. (#68 and #89)stringify no longer throws when an object does not have a prototype. (#154)stringify properly handles the key argument of toJSON(key) methods. toJSON5(key) follows this pattern.stringify accepts Number and String objects as its space argument.stringify also accepts an array of keys to include in the output as its replacer argument. Numbers, Number objects, and String objects will be converted to a string if they are given as array values.This release includes a minor fix for indentations when stringifying empty arrays.
This release includes major internal changes and public API enhancements.
parse and the CLI provide line and column numbers when displaying error messages. (#101; awesome work by @amb26.)Note that v0.3.0 was tagged, but never published to npm, so this v0.4.0 changelog entry includes v0.3.0 features.
This is a massive release that adds stringify support, among other things.
JSON5.stringify() now exists! This method is analogous to the native JSON.stringify(); it just avoids quoting keys where possible. See the usage documentation for more. (#32; huge thanks and props @aeisenberg!)NaN and -NaN are now allowed number literals. (#30; thanks @rowanhill.)-0xC8) are allowed again. (They were disallowed in v0.2.0; see below.) It turns out they are valid in ES5, so JSON5 supports them now too. (#36; thanks @jordanbtucker!)This release fixes some bugs and adds some more utility features to help you express data more easily:
-0xC8) are rejected now. While V8 (e.g. Chrome and Node) supported them, it turns out they're invalid in ES5. This has been fixed in V8 (and by extension, Chrome and Node), so JSON5 officially rejects them now, too. (#36)Infinity and -Infinity are now allowed number literals. (#30; thanks @pepkin88.)+) in front of numbers are now allowed, since it can be helpful in some contexts to explicitly mark numbers as positive. (E.g. when a property represents changes or deltas.)This release tightens JSON5 support and adds helpful utility features:
SyntaxError instances on errors now.require() hook. Register via json5/lib/require.json5 executable to compile JSON5 files to JSON.This was the first implementation of this JSON5 parser.
Let's consider this to be Douglas Crockford's original json_parse.js — a parser for the regular JSON format.