elemental.json.impl.
Class JsonUtil
- java.lang.Object
-
- elemental.json.impl.JsonUtil
-
public class JsonUtil extends Object
Direct port of json2.js at http://www.json.org/json2.js to GWT.
-
-
Constructor Summary
Constructors Constructor and Description JsonUtil()
-
Method Summary
All Methods Modifier and Type Method and Description static String
escapeControlChars(String text)
Convert special control characters into unicode escape format.
static <T extends JsonValue>
Tparse(String json)
static String
quote(String value)
Safely escape an arbitrary string as a JSON string literal.
static String
stringify(JsonValue jsonValue)
Converts a Json Object to Json format.
static String
stringify(JsonValue jsonValue, int spaces)
Converts a JSO to Json format.
static String
stringify(JsonValue jsonValue, String indent)
Converts a Json object to Json formatted String.
-
-
-
Method Detail
-
escapeControlChars
public static String escapeControlChars(String text)
Convert special control characters into unicode escape format.
-
parse
public static <T extends JsonValue> T parse(String json) throws JsonException
Throws:
-
quote
public static String quote(String value)
Safely escape an arbitrary string as a JSON string literal.
-
stringify
public static String stringify(JsonValue jsonValue)
Converts a Json Object to Json format.
Parameters:
jsonValue
- json object to stringifyReturns:
json formatted string
-
stringify
public static String stringify(JsonValue jsonValue, int spaces)
Converts a JSO to Json format.
Parameters:
jsonValue
- json object to stringifyspaces
- number of spaces to indent in pretty print modeReturns:
json formatted string
-
-