]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/pretty-json/node_modules/jsonminify/README.md
Update atoms
[rbdr/dotfiles] / atom / packages / pretty-json / node_modules / jsonminify / README.md
1 # About
2
3 ![Travis CI](https://travis-ci.org/fkei/JSON.minify.png?branch=master)
4
5
6 # Feature
7
8 /*! JSON.minify()
9 v0.1 (c) Kyle Simpson
10 MIT License
11 */
12
13 JSON.minify() minifies blocks of JSON-like content into valid JSON by removing all
14 whitespace *and* comments.
15
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:
19
20 JSON.parse(JSON.minify(str));
21
22 Now you can maintain development-friendly JSON documents, but minify them before
23 parsing or before transmitting them over-the-wire.
24
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.
27
28 http://tech.groups.yahoo.com/group/json/message/152
29
30 "A JSON encoder MUST NOT output comments. A JSON decoder MAY accept and ignore comments."
31
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()
34 is for.
35
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.
38
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.
43
44 # install
45
46 ## npm repo
47
48 ```
49 $ npm install jsonminify
50 ```
51
52 ## npm source
53
54 ```
55 $ npm install https://github.com/fkei/JSON.minify.git
56 ```
57
58 # example
59
60
61 ```javascript
62 var jsonminify = require("jsonminify");
63
64 jsonminify('{"key":"value"/** comment **/}')
65 >> '{"key":"value"}'
66
67 JSON.minify('{"key":"value"/** comment **/}')
68 >> '{"key":"value"}'
69 ```
70
71 # command-line
72
73 Please use here. Use JSON.minify internally.
74
75 **node-mjson** [https://github.com/fkei/node-mjson](https://github.com/fkei/node-mjson)
76
77
78 # build
79
80 ```
81 $ make
82 ```
83
84 # release
85
86 ```
87 $ make release
88 ```
89
90 # test
91
92 ```
93 $ make test
94 ```
95
96 # jshint
97
98 ```
99 $ make jshint
100 ```
101
102 # Document
103
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)
107
108 # Web-Site
109
110 **[Github pages - JSON.minify Home Page](http://fkei.github.io/JSON.minify/)**
111
112 # LICENSE
113
114 forked from [getify/JSON.minify](https://github.com/getify/JSON.minify)
115
116 ```
117 The MIT License (MIT)
118
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:
120
121 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
122
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.
124 ```