{"name":"hjson","description":"JSON for Humans","main":"./lib/hjson.js","author":{"name":"Christian Zangl"},"version":"0.1.0","tags":["json","hjson"],"keywords":["json","hjson"],"homepage":"http://laktak.github.io/hjson","repository":{"type":"git","url":"https://github.com/laktak/hjson-js.git"},"bugs":{"url":"https://github.com/laktak/hjson-js/issues"},"licenses":[{"type":"MIT","url":"https://github.com/laktak/hjson-js/raw/master/LICENSE"}],"_id":"hjson@0.1.0","dist":{"shasum":"f623f60b3f6d844ff1494e0aab56607d6ee36b80","tarball":"http://registry-npm.ywwl.com/hjson/download/hjson-0.1.0.tgz","integrity":"sha512-/pD9jJPx4VYH/R5eiIlzmxqx9Sb0GImEaA2HsMNznOkQ7sjTEJ/QPUwf4Fv5xnM/XiAZQebPtDxoavRPAsLE8Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDUdg4CoPOuhbxaVHsZeU1XXVC73Qbc4uL+Cn4dxYvf/AiByYA0C9oD4ka+HGjp3qECeTKHeHsYT/7jtPBwcrqxa1Q=="}],"size":6546,"noattachment":false,"key":"/hjson/-/hjson-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.21","_npmUser":{"name":"laktak","email":"coralllama@gmail.com"},"maintainers":[{"name":"laktak","email":"coralllama@gmail.com"}],"directories":{},"readme":"# hjson-js\n\n[![Build Status](https://img.shields.io/travis/hjson/hjson-js.svg?style=flat-square)](http://travis-ci.org/hjson/hjson-js)\n[![NPM version](https://img.shields.io/npm/v/hjson.svg?style=flat-square)](http://www.npmjs.com/package/hjson)\n[![License](https://img.shields.io/github/license/hjson/hjson-js.svg?style=flat-square)](https://github.com/hjson/hjson-js/blob/master/LICENSE)\n\n[Hjson](https://hjson.github.io), a user interface for JSON\n\n![Hjson Intro](https://hjson.github.io/hjson1.gif)\n\nJSON is easy for humans to read and write... in theory. In practice JSON gives us plenty of opportunities to make mistakes without even realizing it.\n\nHjson is a syntax extension to JSON. It's NOT a proposal to replace JSON or to incorporate it into the JSON spec itself. It's intended to be used like a user interface for humans, to read and edit before passing the JSON data to the machine.\n\n```Hjson\n{\n  # specify rate in requests/second (because comments are helpful!)\n  rate: 1000\n\n  // prefer c-style comments?\n  /* feeling old fashioned? */\n\n  # did you notice that rate doesn't need quotes?\n  hey: look ma, no quotes for strings either!\n\n  # best of all\n  notice: []\n  anything: ?\n\n  # yes, commas are optional!\n}\n```\n\nThe JavaScript implementation of Hjson is based on [JSON-js](https://github.com/douglascrockford/JSON-js). For other platforms see [hjson.github.io](https://hjson.github.io).\n\n# Install from npm\n\n```\nnpm install hjson\n```\n\n# Usage\n\n```\nvar Hjson = require('hjson');\n\nvar obj = Hjson.parse(hjsonText);\nvar text2 = Hjson.stringify(obj);\n```\n\nTo keep comments intact see [API](#modify--keep-comments).\n\n## From the Commandline\n\nInstall with `npm install hjson -g`.\n\n```\nUsage:\n  hjson [OPTIONS]\n  hjson [OPTIONS] INPUT\n  hjson (-h | --help | -?)\n  hjson (-V | --version)\n\nINPUT can be in JSON or Hjson format. If no file is given it will read from stdin.\nThe default is to output as Hjson.\n\nOptions:\n  (-j | -json)  output as formatted JSON.\n  (-c | -json=compact)  output as JSON.\nOptions for Hjson output:\n  -sl         output the opening brace on the same line\n  -quote      quote all strings\n  -quote=all  quote keys as well\n  -js         output in JavaScript/JSON compatible format\n              can be used with -rt and // comments\n  -rt         round trip comments\n  -nocol      disable colors\n  -cond=n     set condense option (default 60, 0 to disable)\n\nDomain specific formats are optional extensions to Hjson and can be enabled with the following options:\n  +math: support for Inf/inf, -Inf/-inf, Nan/naN and -0\n  +hex: parse hexadecimal numbers prefixed with 0x\n  +date: support ISO dates\n```\n\nSample:\n- run `hjson -j test.hjson > test.json` to convert to JSON\n- run `hjson test.json > test.hjson` to convert to Hjson\n- run `hjson test.json` to view colorized output\n\n\n# API\n\nThe API is the same for the browser and node.js version.\n\n**NOTE that the DSF api is considered experimental**\n\n### Hjson.parse(text, options)\n\nThis method parses *JSON* or *Hjson* text to produce an object or array.\n\n- *text*: the string to parse as JSON or Hjson\n- *options*: object\n  - *keepWsc*: boolean, keep white space and comments. This is useful if you want to edit an hjson file and save it while preserving comments (default false)\n\n### Hjson.stringify(value, options)\n\nThis method produces Hjson text from a JavaScript value.\n\n- *value*: any JavaScript value, usually an object or array.\n- *options*: object\n  - *keepWsc*: boolean, keep white space. See parse.\n  - *condense*: integer, will try to fit objects/arrays onto one line. Default 0 (off).\n  - *bracesSameLine*: boolean, makes braces appear on the same line as the key name. Default false.\n  - *emitRootBraces*: boolean, show braces for the root object. Default true.\n  - *quotes*: string, controls how strings are displayed. (setting separator implies \"strings\")\n    - \"min\": no quotes whenever possible (default)\n    - \"keys\": use quotes around keys\n    - \"strings\": use quotes around string values\n    - \"all\": use quotes around keys and string values\n  - *multiline*: string, controls how multiline strings are displayed. (setting quotes implies \"off\")\n    - \"std\": strings containing \\n are shown in multiline format (default)\n    - \"no-tabs\": like std but disallow tabs\n    - \"off\": show in JSON format\n  - *separator*: boolean, output a comma separator between elements. Default false\n  - *space*: specifies the indentation of nested structures. If it is a number, it will specify the number of spaces to indent at each level. If it is a string (such as '\\t' or '&nbsp;'), it contains the characters used to indent at each level.\n  - *eol*: specifies the EOL sequence (default is set by Hjson.setEndOfLine())\n  - *colors*: boolean, output ascii color codes\n  - *serializeDeterministically*: boolean, when serializing objects into hjson, order the keys based on their UTF-16 code units order. Default false.\n\n### Hjson.endOfLine(), .setEndOfLine(eol)\n\nGets or sets the stringify EOL sequence ('\\n' or '\\r\\n'). When running with node.js this defaults to os.EOL.\n\n### Hjson.rt { parse, stringify }\n\nThis is a shortcut to roundtrip your comments when reading and updating a config file. It is the same as specifying the keepWsc option for the parse and stringify functions.\n\n### Hjson.version\n\nThe version number.\n\n### require-hook\n\nRequire a config file directly.\n\n```\nrequire(\"hjson/lib/require-config\");\nvar cfg=require(\"./config.hjson\");\n```\n\n## modify & keep comments\n\nYou can modify a Hjson file and keep the whitespace & comments intact (round trip). This is useful if an app updates its config file.\n\n```\n// parse, keep whitespace and comments\n// (they are stored in a non enumerable __COMMENTS__ member)\nvar data = Hjson.rt.parse(text);\n\n// modify like you normally would\ndata.foo = \"text\";\n\n// convert back to Hjson\nconsole.log(Hjson.rt.stringify(data));\n```\n# Build\n\nTo run all tests and create the bundle output, first install the dev dependencies with `npm i` and then run `npm run build`.\n\n# History\n\n[see history.md](history.md)\n\n","publish_time":1395264592538,"_cnpm_publish_time":1395264592538,"dist-tags":{"latest":"3.2.2"}}