Commit 295be91c authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Remove third_party/json_minify.

json minify was landed in r124878. Chromium stopped using it in r132692,
but not all files were removed. Removing it completely.

Review URL: https://codereview.chromium.org/11416227

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171053 0039d316-1c4b-4281-b951-d872f2087c98
parent 86d3aca4
Copyright (c) Kyle Simpson
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:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
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.
/*! JSON.minify()
v0.1 (c) Kyle Simpson
MIT License
*/
JSON.minify() minifies blocks of JSON-like content into valid JSON by removing all
whitespace *and* comments.
JSON parsers (like JavaScript's JSON.parse() parser) generally don't consider JSON
with comments to be valid and parseable. So, the intended usage is to minify
development-friendly JSON (with comments) to valid JSON before parsing, such as:
JSON.parse(JSON.minify(str));
Now you can maintain development-friendly JSON documents, but minify them before
parsing or before transmitting them over-the-wire.
Though comments are not officially part of the JSON standard, this post from
Douglas Crockford back in late 2005 helps explain the motivation behind this project.
http://tech.groups.yahoo.com/group/json/message/152
"A JSON encoder MUST NOT output comments. A JSON decoder MAY accept and ignore comments."
Basically, comments are not in the JSON *generation* standard, but that doesn't mean
that a parser can't be taught to ignore them. Which is exactly what JSON.minify()
is for.
The first implementation of JSON.minify() is in JavaScript, but the intent is to
port the implementation to as many other environments as possible/practical.
NOTE: As transmitting bloated (ie, with comments/whitespace) JSON would be wasteful
and silly, this JSON.minify() is intended for use in server-side processing
environments where you can strip comments/whitespace from JSON before parsing
a JSON document, or before transmitting such over-the-wire from server to browser.
\ No newline at end of file
Name: JSON.minify
URL: https://github.com/getify/JSON.minify
and also https://github.com/kitcambridge/JSON.minify
Version: 0.1
License: MIT License
Security Critical: no
Description:
A set of scripts that remove comments and whitespace from JSON files.
Local Modifications:
- Got the (much faster) json-minify-sans-regexp.js file from the second
URL listed
- Removed minify_json.py, it is crazy slow. See commit for replacement.
/*!
* `JSON.minify()`
* This version does not use regular expressions.
*
* Copyright 2011, Kyle Simpson.
* Copyright 2012, Kit Cambridge.
*
* Released under the MIT License.
*/
;(function () {
var JSON = this.JSON;
// Create the global JSON object if it doesn't exist.
if (Object(JSON) !== JSON) {
JSON = this.JSON = {};
}
JSON.minify = function (source) {
var index = 0, length = source.length, result = "", symbol, position;
while (index < length) {
symbol = source.charAt(index);
switch (symbol) {
// Ignore whitespace tokens. According to ES 5.1 section 15.12.1.1,
// whitespace tokens include tabs, carriage returns, line feeds, and
// space characters.
// -----------------------------------------------------------------
case "\t":
case "\r":
case "\n":
case " ":
index += 1;
break;
// Ignore line and block comments.
// -------------------------------
case "/":
symbol = source.charAt(index += 1);
switch (symbol) {
// Line comments.
// -------------
case "/":
position = source.indexOf("\n", index);
if (position < 0) {
// Check for CR-style line endings.
position = source.indexOf("\r", index);
}
index = position > -1 ? position : length;
break;
// Block comments.
// ---------------
case "*":
position = source.indexOf("*/", index);
if (position > -1) {
// Advance the scanner's position past the end of the comment.
index = position += 2;
break;
}
throw SyntaxError("Unterminated block comment.");
default:
throw SyntaxError("Invalid comment.");
}
break;
// Parse strings separately to ensure that any whitespace characters and
// JavaScript-style comments within them are preserved.
// ---------------------------------------------------------------------
case '"':
position = index;
while (index < length) {
symbol = source.charAt(index += 1);
if (symbol == "\\") {
// Skip past escaped characters.
index += 1;
} else if (symbol == '"') {
break;
}
}
if (source.charAt(index) == '"') {
result += source.slice(position, index += 1);
break;
}
throw SyntaxError("Unterminated string.");
// Preserve all other characters.
// ------------------------------
default:
result += symbol;
index += 1;
}
}
return result;
};
}).call(this);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment