{"_id":"json-literal","_rev":"1070294","name":"json-literal","description":"superset of `JSON` adding date, regex, null and octal literals","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"time":{"modified":"2024-10-04T00:44:31.000Z","created":"2013-07-12T23:42:26.099Z","1.1.0":"2013-08-06T03:46:51.797Z","1.0.0":"2013-07-12T23:42:26.099Z"},"users":{},"author":{"name":"ForbesLindesay"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/json-literal.git"},"versions":{"1.1.0":{"name":"json-literal","version":"1.1.0","description":"superset of `JSON` adding date, regex, null and octal literals","keywords":[],"dependencies":{"esprima":"~1.0.3","type-of":"~2.0.0"},"devDependencies":{"mocha":"*","garbage":"*"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/json-literal.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","readmeFilename":"README.md","bugs":{"url":"https://github.com/ForbesLindesay/json-literal/issues"},"_id":"json-literal@1.1.0","dist":{"shasum":"60bd4fc601c1408814922d2e42ac4f23da657406","tarball":"http://registry-npm.ywwl.com/json-literal/download/json-literal-1.1.0.tgz","integrity":"sha512-tqQCvS0FpENGay/tbuoxNpEV30HMvRKJVSNBEvgMLlCY9nQLW7AGfhrGkasbqFdKJz5DRf9mt3GjFuGde7G/rg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHsV98Wj8bn8XrOxqrQV4zwUNAxgiOPy6g5rtyJFF+8FAiEAn/wZNYiRjOZofjMaO692Y6LcXtLThNwcaiWbbVHltrU="}],"size":4595,"noattachment":false,"key":"/json-literal/-/json-literal-1.1.0.tgz"},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"publish_time":1375760811797,"_cnpm_publish_time":1375760811797},"1.0.0":{"name":"json-literal","version":"1.0.0","description":"superset of `JSON` adding date, regex, null and octal literals","keywords":[],"dependencies":{"esprima":"~1.0.3","type-of":"~2.0.0"},"devDependencies":{"mocha":"*","garbage":"*"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/json-literal.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","readmeFilename":"README.md","_id":"json-literal@1.0.0","dist":{"shasum":"c4b263f397edb300a6ad63e48107cdcf7e6dee6e","tarball":"http://registry-npm.ywwl.com/json-literal/download/json-literal-1.0.0.tgz","integrity":"sha512-9wYawR8auBKlwPUhZvEE5wJ52aTBW2tWtaqhqOtEm/WWWq/lu/bUdUr8uIaz+65l6lgbke+rDERODpD3aG/+5Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDrUsyoyD5bF2fdIVhDC73kuyDVwVAX/o65rqXlXEvRcwIgFe23be/bhOD4C+XUEWC7UlSvV3eiv8TyX4Ar4d6WYng="}],"size":3871,"noattachment":false,"key":"/json-literal/-/json-literal-1.0.0.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{},"publish_time":1373672546099,"_cnpm_publish_time":1373672546099}},"readme":"# json-literal\r\n\r\nSuperset of `JSON` adding circular references, date, regex, null, undefined and octal literals while also making it more flexible so as to be easier to read and write.  Inspired by [@substack](https://github.com/substack)'s [json-literal-parse](https://github.com/substack/json-literal-parse).\r\n\r\nKey Points:\r\n\r\n - Secure Parser, it does not use 'eval', except on something that's just been through `JSON.stringify` to sanitize it.\r\n - Stringifier does not produce valid JSON, it writes un-quoted keys when possible, and includes RegExp and Date Literals.\r\n - The stringifier and parser both represent circular refernces internally as `new Circular(\"path\", \"to\", \"canonical\", \"instance\", \"of\", \"object\")`\r\n - The parser understands any Date of the form `new Date(...args)`\r\n - The parser understands any RegExp of the form `/regexp/gi`\r\n - The parser accepts un-quoted keys, providing they are valid identifiers (e.g. `{a: 5, b: \"foo\"}`)\r\n - The parser accepts either `\"` or `'` as quotes for strings\r\n - The parser allows comments as both `// line comment` and `/* inline comment */`\r\n\r\n[![Build Status](https://travis-ci.org/ForbesLindesay/json-literal.png?branch=master)](https://travis-ci.org/ForbesLindesay/json-literal)\r\n[![Dependency Status](https://gemnasium.com/ForbesLindesay/json-literal.png)](https://gemnasium.com/ForbesLindesay/json-literal)\r\n[![NPM version](https://badge.fury.io/js/json-literal.png)](http://badge.fury.io/js/json-literal)\r\n\r\n## Installation\r\n\r\n    npm install json-literal\r\n\r\n## Example\r\n\r\n\r\ne.g.\r\n\r\n```js\r\nvar JSONL = require('json-literal')\r\nvar str = JSONL.stringify({\r\n  str: 'This is a string',\r\n  'some-attributes-require-quotes': 10,\r\n  updated: new Date('2013-07-12T15:42:00.000Z'),\r\n  match: /^\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d$/\r\n})\r\n// => '({str:\"This is a string\",\"some-attributes-require-quotes\":10,updated:new Date(\"2013-07-12T15:42:00.000Z\"),match:/^\\\\d\\\\d\\\\d\\\\d\\\\-\\\\d\\\\d\\\\-\\\\d\\\\d$/})'\r\nvar obj = JSONL.parse(str)\r\n// => { str: 'This is a string',\r\n//      'some-attributes-require-quotes': 10,\r\n//      updated: new Date('2013-07-12T15:42:00.000Z'),\r\n//      match: /^\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d$/ }\r\n```\r\n\r\n## API\r\n\r\n```js\r\nvar JSONL = require('json-literal')\r\n```\r\n\r\n### var obj = JSONL.parse(str)\r\n\r\nParse the input string `str`, returning the parsed representation `obj`.\r\n\r\n`JSONL.parse()` is just like `JSON.parse()` except that the input may have additional \"literal\" types not in the JSON spec, which are:\r\n\r\n - date (as `new Date(...args)`)\r\n - regex\r\n - null\r\n - undefined\r\n - octal\r\n\r\nand input can contain comments of the form:\r\n\r\n - `// line comment`\r\n - `/* inline comment */`\r\n\r\nYou may optionally denote a JSONL string as not being a JSON string by surrounding it with parentheses, which will be stripped during parsing.\r\n\r\n### var str = JSONL.stringify(obj)\r\n\r\nStringify the input object `obj`, returning the string representation `str`.\r\n\r\n`JSONL.stringify()` is just like `JSON.stringify()` except that it supports additional \"literal\" types not in the JSON spec, and will NOT return a valid JSON object.\r\n\r\nTo differentiate the JSONL string from a JSON string, it is placed in parentheses.\r\n\r\n## License\r\n\r\n  MIT","_attachments":{},"readmeFilename":"README.md","bugs":{"url":"https://github.com/ForbesLindesay/json-literal/issues"},"license":"MIT"}