3 ![Travis CI](https://travis-ci.org/fkei/JSON.minify.png?branch=master)
13 JSON.minify() minifies blocks of JSON-like content into valid JSON by removing all
14 whitespace *and* comments.
16 JSON parsers (like JavaScript's JSON.parse() parser) generally don't consider JSON
17 with comments to be valid and parseable. So, the intended usage is to minify
18 development-friendly JSON (with comments) to valid JSON before parsing, such as:
20 JSON.parse(JSON.minify(str));
22 Now you can maintain development-friendly JSON documents, but minify them before
23 parsing or before transmitting them over-the-wire.
25 Though comments are not officially part of the JSON standard, this post from
26 Douglas Crockford back in late 2005 helps explain the motivation behind this project.
28 http://tech.groups.yahoo.com/group/json/message/152
30 "A JSON encoder MUST NOT output comments. A JSON decoder MAY accept and ignore comments."
32 Basically, comments are not in the JSON *generation* standard, but that doesn't mean
33 that a parser can't be taught to ignore them. Which is exactly what JSON.minify()
36 The first implementation of JSON.minify() is in JavaScript, but the intent is to
37 port the implementation to as many other environments as possible/practical.
39 NOTE: As transmitting bloated (ie, with comments/whitespace) JSON would be wasteful
40 and silly, this JSON.minify() is intended for use in server-side processing
41 environments where you can strip comments/whitespace from JSON before parsing
42 a JSON document, or before transmitting such over-the-wire from server to browser.
49 $ npm install jsonminify
55 $ npm install https://github.com/fkei/JSON.minify.git
62 var jsonminify = require("jsonminify");
64 jsonminify('{"key":"value"/** comment **/}')
67 JSON.minify('{"key":"value"/** comment **/}')
73 Please use here. Use JSON.minify internally.
75 **node-mjson** [https://github.com/fkei/node-mjson](https://github.com/fkei/node-mjson)
104 - [JSDoc - API Document](http://fkei.github.io/JSON.minify/docs/index.html)
105 - [Plato - Report](http://fkei.github.io/JSON.minify/report/index.html)
106 - [Mocha - Test result (HTML)](http://fkei.github.io/JSON.minify/TestDoc.html)
110 **[Github pages - JSON.minify Home Page](http://fkei.github.io/JSON.minify/)**
114 forked from [getify/JSON.minify](https://github.com/getify/JSON.minify)
117 The MIT License (MIT)
119 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
121 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
123 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.