Groovy 2.2.1

groovy.json
[Groovy] Class JsonOutput

java.lang.Object
  groovy.json.JsonOutput

class JsonOutput

Class responsible for the actual String serialization of the possible values of a JSON structure. This class can also be used as a category, so as to add toJson() methods to various types.

Authors:
Guillaume Laforge
Roshan Dawrani
Since:
1.8.0


Method Summary
static String prettyPrint(String jsonPayload)

Pretty print a JSON payload

static String toJson(Boolean bool)

@return "true" or "false" for a boolean value

static String toJson(Number n)

@return a string representation for a number

static String toJson(Character c)

@return a JSON string representation of the character

static String toJson(String s)

@return a properly encoded string with escape sequences

static String toJson(Date date)

Format a date that is parseable from JavaScript, according to ISO-8601.

static String toJson(Calendar cal)

Format a calendar instance that is parseable from JavaScript, according to ISO-8601.

static String toJson(UUID uuid)

@return the string representation of an uuid

static String toJson(URL url)

@return the string representation of the URL

static String toJson(Closure closure)

@return an object representation of a closure

static String toJson(Expando expando)

@return an object representation of an Expando

static String toJson(def object)

@return "null" for a null value, or a JSON array representation for a collection, array, iterator or enumeration.

static String toJson(Map m)

@return a JSON object representation for a map

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Method Detail

prettyPrint

@CompileStatic
static String prettyPrint(String jsonPayload)
Pretty print a JSON payload
Parameters:
jsonPayload
Returns:


toJson

@CompileStatic
static String toJson(Boolean bool)
Returns:
"true" or "false" for a boolean value


toJson

static String toJson(Number n)
throws:
JsonException if the number is infinite or not a number.
Returns:
a string representation for a number


toJson

@CompileStatic
static String toJson(Character c)
Returns:
a JSON string representation of the character


toJson

@CompileStatic
static String toJson(String s)
Returns:
a properly encoded string with escape sequences


toJson

@CompileStatic
static String toJson(Date date)
Format a date that is parseable from JavaScript, according to ISO-8601.
Parameters:
date - the date to format to a JSON string
Returns:
a formatted date in the form of a string


toJson

@CompileStatic
static String toJson(Calendar cal)
Format a calendar instance that is parseable from JavaScript, according to ISO-8601.
Parameters:
cal - the calendar to format to a JSON string
Returns:
a formatted date in the form of a string


toJson

@CompileStatic
static String toJson(UUID uuid)
Returns:
the string representation of an uuid


toJson

@CompileStatic
static String toJson(URL url)
Returns:
the string representation of the URL


toJson

static String toJson(Closure closure)
Returns:
an object representation of a closure


toJson

static String toJson(Expando expando)
Returns:
an object representation of an Expando


toJson

static String toJson(def object)
Returns:
"null" for a null value, or a JSON array representation for a collection, array, iterator or enumeration.


toJson

static String toJson(Map m)
Returns:
a JSON object representation for a map


 

Copyright © 2003-2013 The Codehaus. All rights reserved.