{"_id":"hanson","_rev":"65-dea1465c62ff029f7160dda53fed1413","name":"hanson","description":"HanSON is JSON with multiline strings and comments. Includes parser and converter.","dist-tags":{"latest":"1.2.0"},"versions":{"0.0.1":{"name":"hanson","version":"0.0.1","description":"HanSON is JSON with multiline strings and comments. Includes parser and converter.","main":"hanson.js","scripts":{"test":"mocha hanson-test.js"},"repository":{"type":"git","url":"https://github.com/timjansen/hanson.git"},"keywords":["json","hanson"],"author":{"name":"Tim Jansen"},"licenses":[{"type":"Public Domain","url":"http://creativecommons.org/publicdomain/zero/1.0/"}],"devDependencies":{"mocha":"~1.12.0"},"_id":"hanson@0.0.1","dist":{"shasum":"fe564f16250ce6e0f02db80773dd5d2d88be50e8","tarball":"https://registry.npmjs.org/hanson/-/hanson-0.0.1.tgz","integrity":"sha512-BN8bkvrIvV3YZLkS41V/GFGpufbAuWWjnsA4AWJhl7Pf5H5te4MUgHe1p+uk1o6MGlttZ3IZau6hbhl3LQF0UA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBqzQFsha9xiqMpRA55Gm3rMDztpTzMw+AqV+A6PZEoHAiBoUZANxIA82s/4r87fr1XCwmZ9/zwe774lkGFztwm/bw=="}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"tjansen","email":"tim@tjansen.de"},"maintainers":[{"name":"tjansen","email":"tim@tjansen.de"}],"directories":{}},"0.1.0":{"name":"hanson","version":"0.1.0","description":"HanSON is JSON with multiline strings and comments. Includes parser and converter.","main":"hanson.js","scripts":{"test":"mocha hanson-test.js"},"repository":{"type":"git","url":"https://github.com/timjansen/hanson.git"},"keywords":["json","hanson"],"author":{"name":"Tim Jansen"},"licenses":[{"type":"Public Domain","url":"http://unlicense.org/"}],"devDependencies":{"mocha":"~1.12.0"},"bin":{"hanson":"hansoncmd.js"},"homepage":"https://github.com/timjansen/hanson","_id":"hanson@0.1.0","dist":{"shasum":"14631c99f755ed311520e79a64f28db2828fd4ae","tarball":"https://registry.npmjs.org/hanson/-/hanson-0.1.0.tgz","integrity":"sha512-0q9+c9/QuqOToYiXTCuqIaUvt5FWNWLjhKtHDG9h11IK/hhWBGniZmCcuryU2XoZqJZY5IcN6va7eG5ODj7Uaw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC2aeQBsa1oM0o0ueIo7o+kbhHGX8Hjl6b5zpmEhVk/SAiBJceynZF6vk+45lqk+e2hTC39J/qNLn0SSfqOsxqiUDw=="}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"tjansen","email":"tim@tjansen.de"},"maintainers":[{"name":"tjansen","email":"tim@tjansen.de"}],"directories":{}},"1.0.0":{"name":"hanson","version":"1.0.0","description":"HanSON is JSON with multiline strings and comments. Includes parser and converter.","main":"hanson.js","scripts":{"test":"mocha hanson-test.js"},"repository":{"type":"git","url":"https://github.com/timjansen/hanson.git"},"keywords":["json","hanson"],"author":{"name":"Tim Jansen"},"licenses":[{"type":"Public Domain","url":"http://unlicense.org/"}],"devDependencies":{"mocha":"~1.12.0"},"bin":{"hanson":"hansoncmd.js"},"homepage":"https://github.com/timjansen/hanson","_id":"hanson@1.0.0","dist":{"shasum":"8714493380b9dccf30dc1ada216531e4cbb335e6","tarball":"https://registry.npmjs.org/hanson/-/hanson-1.0.0.tgz","integrity":"sha512-wsYLkZ7VtWs/V+9+6RyprQtCGUpvp+VERkzOBKb6c6TAQjyIiWEESxX4p7fOhYeGkB4fSgIfd3mTkB9KIZuGMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICNjA/cVWzVZ3+TWqkroLdkDL/Iv6oT3qkDNgnSaORvzAiEA2i7s29NREEUqyYXrmfDP8y9fD05lcTrRDcv9e/rkOTE="}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"tjansen","email":"tim@tjansen.de"},"maintainers":[{"name":"tjansen","email":"tim@tjansen.de"}],"directories":{}},"1.1.0":{"name":"hanson","version":"1.1.0","description":"HanSON is JSON with multiline strings and comments. Includes parser and converter.","main":"hanson.js","scripts":{"test":"mocha hanson-test.js"},"repository":{"type":"git","url":"https://github.com/timjansen/hanson.git"},"keywords":["json","hanson"],"author":{"name":"Tim Jansen"},"licenses":[{"type":"Public Domain","url":"http://unlicense.org/"}],"devDependencies":{"mocha":"~1.12.0"},"bin":{"hanson":"hansoncmd.js"},"homepage":"https://github.com/timjansen/hanson","_id":"hanson@1.1.0","dist":{"shasum":"a6ee805d24b54e2c6de4a539f2dc2f09adb625c0","tarball":"https://registry.npmjs.org/hanson/-/hanson-1.1.0.tgz","integrity":"sha512-cb3Keq/HLMhgDNa08Uqi+4dt2UHFBYSPANn2kwxeeAwM/OHhm1wcpXFDNLukKxv9F/wSD2C3jaVu5mc/RCNTDw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDToVZ76HSgpMQPvDymDo8CpsHjn2pRBZRpmAFGUbKhhgIgH3xHVs7WvWgrDbeF7Sje5A+v4AtX8+O5A0eu69ccWfA="}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"tjansen","email":"tim@tjansen.de"},"maintainers":[{"name":"tjansen","email":"tim@tjansen.de"}],"directories":{}},"1.1.1":{"name":"hanson","version":"1.1.1","description":"HanSON is JSON with multiline strings and comments. Includes parser and converter.","main":"hanson.js","scripts":{"test":"mocha hanson-test.js"},"repository":{"type":"git","url":"https://github.com/timjansen/hanson.git"},"keywords":["json","hanson"],"author":{"name":"Tim Jansen"},"licenses":[{"type":"Public Domain","url":"http://unlicense.org/"}],"devDependencies":{"mocha":"~1.12.0"},"bin":{"hanson":"hansoncmd.js"},"homepage":"https://github.com/timjansen/hanson","_id":"hanson@1.1.1","dist":{"shasum":"28629871c2cbf4f5a28a130a684e35ee2c923c7a","tarball":"https://registry.npmjs.org/hanson/-/hanson-1.1.1.tgz","integrity":"sha512-HUbGCcRb/yXK31d14hV5LR/7cF6g4U1hdTu9/9xEQFqDPv9vDRPYela8qhH47qt+CIgz3dmVTWjNJwtpqKobsQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDe7r9703v7QhTu1egr6iGslSy0fMd2WobDAm2F1iTwigIhAO3lvSr2UEDEDsMk2BVc+xNpnCtg0ReJW8EIRkk4uKG3"}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"tjansen","email":"tim@tjansen.de"},"maintainers":[{"name":"tjansen","email":"tim@tjansen.de"}]},"1.2.0":{"name":"hanson","version":"1.2.0","description":"HanSON is JSON with multiline strings and comments. Includes parser and converter.","main":"hanson.js","scripts":{"test":"mocha"},"repository":{"type":"git","url":"git+https://github.com/timjansen/hanson.git"},"keywords":["json","hanson"],"author":{"name":"Tim Jansen"},"licenses":[{"type":"Public Domain","url":"http://unlicense.org/"}],"devDependencies":{"chai":"^3.5.0","mocha":"~1.17.1"},"bin":{"hanson":"hansoncmd.js"},"homepage":"https://github.com/timjansen/hanson","gitHead":"b27b452191a598ee19860c0c06d79a082b2829ae","bugs":{"url":"https://github.com/timjansen/hanson/issues"},"_id":"hanson@1.2.0","_shasum":"2d198d5ca03ebccdcaeb7c9d9c492e18405be002","_from":".","_npmVersion":"3.9.5","_nodeVersion":"0.10.17","_npmUser":{"name":"tjansen","email":"tim@tjansen.de"},"dist":{"shasum":"2d198d5ca03ebccdcaeb7c9d9c492e18405be002","tarball":"https://registry.npmjs.org/hanson/-/hanson-1.2.0.tgz","integrity":"sha512-vTUT1uyY0jQ7N/dhvCE7bvczmZ8iIxnSMM9xak33FGA4E8Jhj3SOm33pzZsysuFU36kCfcdUVhe9Y47Lia1lpg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDSWY2i0/AM7t4kgat8x5Votly8KN5CeN1VXvVdW0q6hwIgBF69CZA3OnEJOyBHsyfAbWSLvWIO1zoH/LOtYJAXZC8="}]},"maintainers":[{"name":"tjansen","email":"tim@tjansen.de"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/hanson-1.2.0.tgz_1465936687614_0.27353851217776537"}}},"readme":"HanSON - JSON for Humans\n========================\n\nIn Short\n---------\n* HanSON is JSON with comments, multi-line strings and unquoted property names.\n* Comments use JavaScript syntax (//, /**/).\n* Supports backticks as quotes (``) for multi-line strings.\n* You can use either double-quotes (\"\") or single-quotes ('') for single-line strings.\n* Property names do not require quotes if they are valid JavaScript identifiers.\n* Commas after the last list element or property will be ignored.\n* Every JSON string is valid HanSON.\n* HanSON can easily be converted to real JSON. \n\n\n\nIntro\n------\nJSON is a great and very simple data format, especially if you are working with JavaScript. Increasingly configuration \nfiles are written in JSON, and often it is used as a simpler alternative to XML. Unfortunately, when you are creating\nlarger JSON files by hand, you will notice some shortcomings: you need to quote all strings, even object keys; \nyou can not easily have strings with several lines; and you can not include comments. \n\nHanSON is an extension of JSON that fixes those shortcomings with four simple additions to the JSON spec:\n* quotes for strings are optional if they follow JavaScript identifier rules.\n* you can alternatively use backticks, as in ES6's template string literal, as quotes for strings. \n  A backtick-quoted string may span several lines and you are not required to escape regular quote characters,\n  only backticks. Backslashes still need to be escaped, and all other backslash-escape sequences work like in \n  regular JSON.\n* for single-line strings, single quotes ('') are supported in addition to double quotes (\"\")\n* you can use JavaScript comments, both single line (//) and multi-line comments (/* */), in all places where JSON allows whitespace.\n* Commas after the last list element or object property will be ignored. \n  \n  \n\nExample HanSON\n---------------\n```js\n{\n  listName: \"Sesame Street Monsters\", // note that listName needs no quotes\n  content: [\n    {\n      name: \"Cookie Monster\",\n      /* Note the template quotes and unescaped regular quotes in the next string */\n      background: `Cookie Monster used to be a\nmonster that ate everything, especially cookies.\nThese days he is forced to eat \"healthy\" food.`\n    }, {\n      name: \"Herry Monster\",\n      background: `Herry Monster is a furry blue monster with a purple nose.\nHe's mostly retired today.`\n    },    // don't worry, the trailing comma will be ignored\n   ]\n}\n```\n  \n  \nConverting HanSON to JSON\n----------------------------\n*hanson* is a command-line converter that will convert HanSON files to JSON. \nIt is a Nodes.js package that can be installed using npm:\n> npm install -g hanson\n\nAfter installation, convert a single file like this:\n> hanson input.hson output.json\n\nYou can also convert multiple files using the -m options. It will automatically change the file extension to .json:\n> hanson -m input1.hson input2.hson input3.hson input4.hson input5.hson\n\n\n\nGrunt Task to Convert HanSON to JSON\n--------------------------------------\n\nThe Grunt plugin <a href=\"https://github.com/timjansen/grunt-hanson-plugin\">grunt-hanson-plugin</a> can help you converting \nHanSON files to JSON. More about it in its own <a href=\"https://github.com/timjansen/grunt-hanson-plugin\">repository</a>.\n\n\nWebpack loader to Convert HanSON to JSON\n--------------------------------------\n\nThe Webpack loader [hson-loader](https://github.com/kentcdodds/hson-loader) can help you converting HanSON files to JSON. More\nabout it in its own [repository](https://github.com/kentcdodds/hson-loader).\n\n\nReading HanSON in JavaScript\n-------------------------------\n*hanson.js* is a simple library for Node.js that provides you with a HanSON object which works pretty much like the *JSON*\nobject, with the only difference being that hanson.parse() will accept HanSON.\n\n```js\nvar hanson = require('hanson');\nvar obj = hanson.parse(hansonSrc);\n```\n \nhanson.stringify() will currently write regular JSON and just invokes JSON.stringify(), but future versions may pretty-print \nthe output and use triple-quotes for multi-line strings instead of '\\n'.\n\nThere's also a toJSON() function that can convert your HanSON source into JSON:\n```js\nvar hanson = require('hanson');\nvar json = hanson.parse(hansonSrc);\n```\n\n\n\nHow Can HanSON Help Me?\n--------------------------\n* If you have configuration or descriptor files (like package.json), you can write them as HanSON and convert them \n  with the command line tool or the Grunt task.\n* Multi-line strings make it feasible to use JSON/HanSON for larger template systems, e.g. to generate static HTML pages. \n  Just write a small script that accepts HanSON and uses your favorite JavaScript template engine to create HTML.\n  Actually this is why I started HanSON - I wanted to replace my XSLT-based template system.\n* You can, of course, extend your application to accept HanSON files.\n\n\n\nFunction to Convert HanSON\n----------------------------\nWant to use HanSON in your program, without including any libraries? Use this function to convert\nHanSON to JSON. It returns a JSON string that can be read using JSON.parse().\n\n```js\nfunction toJSON(input) {\n\t\tvar UNESCAPE_MAP = { '\\\\\"': '\"', \"\\\\`\": \"`\", \"\\\\'\": \"'\" };\n\t\tvar ML_ESCAPE_MAP = {'\\n': '\\\\n', \"\\r\": '\\\\r', \"\\t\": '\\\\t', '\"': '\\\\\"'};\n\t\tfunction unescapeQuotes(r) { return UNESCAPE_MAP[r] || r; }\n\t\t\n\t\treturn input.replace(/`(?:\\\\.|[^`])*`|'(?:\\\\.|[^'])*'|\"(?:\\\\.|[^\"])*\"|\\/\\*[^]*?\\*\\/|\\/\\/.*\\n?/g, // pass 1: remove comments \n\t\t\t\t\t\t\t function(s) {\n\t\t\tif (s.charAt(0) == '/')\n\t\t\t\treturn '';\n\t\t\telse  \n\t\t\t\treturn s;\n\t\t})\n\t\t.replace(/(?:true|false|null)(?=[^\\w_$]|$)|([a-zA-Z_$][\\w_$]*)|`((?:\\\\.|[^`])*)`|'((?:\\\\.|[^'])*)'|\"(?:\\\\.|[^\"])*\"|(,)(?=\\s*[}\\]])/g, // pass 2: requote \n\t\t\t\t\t\t\t function(s, identifier, multilineQuote, singleQuote, lonelyComma) {\n\t\t\tif (lonelyComma)\n\t\t\t\treturn '';\n\t\t\telse if (identifier != null)\n\t\t\t\t\treturn '\"' + identifier + '\"';\n\t\t\telse if (multilineQuote != null)\n\t\t\t\treturn '\"' + multilineQuote.replace(/\\\\./g, unescapeQuotes).replace(/[\\n\\r\\t\"]/g, function(r) { return ML_ESCAPE_MAP[r]; }) + '\"';\n\t\t\telse if (singleQuote != null)\n\t\t\t\treturn '\"' + singleQuote.replace(/\\\\./g, unescapeQuotes).replace(/\"/g, '\\\\\"') + '\"';\n\t\t\telse \n\t\t\t\treturn s;\n\t\t});\n}\n```\n\nChanges\n--------\n* August 14, 2013: First release (0.1.0)\n* August 15, 2013: Replaced triple-quotes with backticks (1.0.0, backward-incompatible change)\n* August 19, 2013: Added support for single-quotes (1.1.0)\n* June 14, 2016: Support for STDIN/STDOUT in command line. Improved tests. Thank you, Matt Carter (1.2.0)\n\n\nLicense\n--------\nAll code and documentation has been dedicated to the public domain:\nhttp://unlicense.org/\n\n\n\n\n\n\n  \n","maintainers":[{"name":"tjansen","email":"tim@tjansen.de"}],"time":{"modified":"2022-06-18T18:58:27.978Z","created":"2013-08-13T21:58:20.107Z","0.0.1":"2013-08-13T21:58:22.178Z","0.1.0":"2013-08-14T23:31:02.675Z","1.0.0":"2013-08-15T22:31:44.966Z","1.1.0":"2013-08-18T23:00:03.044Z","1.1.1":"2013-08-19T00:01:40.321Z","1.2.0":"2016-06-14T20:38:11.191Z"},"author":{"name":"Tim Jansen"},"repository":{"type":"git","url":"git+https://github.com/timjansen/hanson.git"},"users":{"shanewholloway":true,"hash-bang":true,"mastert":true},"homepage":"https://github.com/timjansen/hanson","keywords":["json","hanson"],"bugs":{"url":"https://github.com/timjansen/hanson/issues"},"readmeFilename":"README.md"}