|
GWT 2.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.core.client.JsonUtils
public class JsonUtils
Provides JSON-related utility methods.
Method Summary | ||
---|---|---|
static java.lang.String |
escapeJsonForEval(java.lang.String toEscape)
Escapes characters within a JSON string than cannot be passed directly to eval(). |
|
static java.lang.String |
escapeValue(java.lang.String toEscape)
Returns a quoted, escaped JSON String. |
|
static
|
safeEval(java.lang.String json)
Evaluates a JSON expression safely. |
|
static boolean |
safeToEval(java.lang.String text)
Returns true if the given JSON string may be safely evaluated by eval() without undersired side effects or security risks. |
|
static
|
unsafeEval(java.lang.String json)
Evaluates a JSON expression using eval() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String escapeJsonForEval(java.lang.String toEscape)
public static java.lang.String escapeValue(java.lang.String toEscape)
public static <T extends JavaScriptObject> T safeEval(java.lang.String json)
T
- The type of JavaScriptObject that should be returnedjson
- The source JSON text
java.lang.IllegalArgumentException
- if the input is not valid JSONpublic static boolean safeToEval(java.lang.String text)
eval()
without undersired side effects or security risks. Note that a true
result from this method does not guarantee that the input string is valid
JSON. This method does not consider the contents of quoted strings; it
may still be necessary to perform escaping prior to evaluation for correct
results.
The technique used is taken from RFC 4627.
public static <T extends JavaScriptObject> T unsafeEval(java.lang.String json)
eval()
. This method does not
validate the JSON text and should only be used on JSON from trusted
sources. The payload must evaluate to an Object or an Array (not a
primitive or a String).
T
- The type of JavaScriptObject that should be returnedjson
- The source JSON text
|
GWT 2.2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |