public class JsonOutput
Temporary fork of groovy.json.JsonOutput until Groovy 2.5.0 is out.
Class responsible for the actual String serialization of the possible values of a JSON structure.
This class can also be used as a category, to add toJson()
methods to various types.
Modifiers | Name | Description |
---|---|---|
static class |
JsonOutput.JsonUnescaped |
Represents unescaped JSON |
static class |
JsonOutput.JsonWritable |
Represents unescaped JSON |
Modifiers | Name | Description |
---|---|---|
static char |
CLOSE_BRACE |
|
static char |
CLOSE_BRACKET |
|
static char |
COLON |
|
static char |
COMMA |
|
static JsonGenerator |
DEFAULT_GENERATOR |
|
static java.lang.String |
DEFAULT_TIMEZONE |
|
static char[] |
EMPTY_LIST_CHARS |
|
static char[] |
EMPTY_MAP_CHARS |
|
static char[] |
EMPTY_STRING_CHARS |
|
static java.lang.String |
JSON_DATE_FORMAT |
|
static char |
NEW_LINE |
|
static java.lang.String |
NULL_VALUE |
|
static char |
OPEN_BRACE |
|
static char |
OPEN_BRACKET |
|
static char |
QUOTE |
|
static char |
SPACE |
Type Params | Return Type | Name and description |
---|---|---|
|
private static char[] |
getIndent(int indentSize, java.util.Map<java.lang.Integer, char[]> indentCache) Creates new indent if it not exists in the indent cache. |
|
public static java.lang.String |
prettyPrint(java.lang.String jsonPayload) Pretty print a JSON payload. |
|
public static java.lang.String |
toJson(java.lang.Boolean bool)
|
|
public static java.lang.String |
toJson(java.lang.Number n)
|
|
public static java.lang.String |
toJson(java.lang.Character c)
|
|
public static java.lang.String |
toJson(java.lang.String s)
|
|
public static java.lang.String |
toJson(java.util.Date date) Format a date that is parseable from JavaScript, according to ISO-8601. |
|
public static java.lang.String |
toJson(java.util.Calendar cal) Format a calendar instance that is parseable from JavaScript, according to ISO-8601. |
|
public static java.lang.String |
toJson(java.util.UUID uuid)
|
|
public static java.lang.String |
toJson(java.net.URL url)
|
|
public static java.lang.String |
toJson(groovy.lang.Closure closure)
|
|
public static java.lang.String |
toJson(groovy.util.Expando expando)
|
|
public static java.lang.String |
toJson(java.lang.Object object)
|
|
public static java.lang.String |
toJson(java.util.Map m)
|
|
public static JsonOutput.JsonUnescaped |
unescaped(java.lang.CharSequence text) Obtains JSON unescaped text for the given text |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Creates new indent if it not exists in the indent cache.
Pretty print a JSON payload.
jsonPayload
- a JSON payload
bool
- a java.lang.Booleann
- a java.lang.Number to write as JSON string
c
- a java.lang.Character
s
- a java.lang.String to be represented in JSONFormat a date that is parseable from JavaScript, according to ISO-8601.
date
- the date to format to a JSON stringFormat a calendar instance that is parseable from JavaScript, according to ISO-8601.
cal
- the calendar to format to a JSON string
uuid
- a java.util.UUID
url
- a java.net.URL
closure
- a groovy.lang.Closure to format to JSON string
expando
- a groovy.util.Expando object to format to JSON string
object
- an java.lang.Object to format to JSON string
m
- a java.util.Map to format to JSON stringObtains JSON unescaped text for the given text
text
- The text