com.google.json
Class EvalMinifier
java.lang.Object
com.google.json.EvalMinifier
public final class EvalMinifier
- extends Object
Given a string of valid JSON that is going to be parsed via Javascript's
eval builtin, tries to reduce the number of bytes sent over
the wire by turning it into a Javascript expression that pools constants.
|
Method Summary |
static String |
minify(String jsonish)
Renders JSON-like content safe for use with Javascript eval. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EvalMinifier
public EvalMinifier()
minify
public static String minify(String jsonish)
- Renders JSON-like content safe for use with Javascript
eval.
The output is a Javascript expression, not a statement, so if it
contains an object ({properties}) then it
still needs to be wrapped in parentheses before being passed to
eval as via eval('(' + s + ')') or eval('0,' + s).
- Parameters:
jsonish - a string of JSON-like content as defined by
JsonSanitizer.
- Returns:
- a valid Javascript expression that has no free variables and whose
execution will have no side-effects, and which can be embedded safely in
an HTML
<script></script> element or inside an XML
<![CDATA[...]]> section.
Copyright © 2014. All Rights Reserved.