|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.linkedin.groovy.util.json.JsonUtils
class JsonUtils
Contains utilities for json.
Method Summary | |
---|---|
static java.lang.Object
|
collectionToJSON(java.util.Collection list)
|
static java.lang.Object
|
fromJSON(java.lang.String json)
Given a json string, convert it to a value (maps / lists): equivalent to
|
static java.lang.Object
|
mapToJSON(java.util.Map map)
|
static java.lang.String
|
prettyPrint(java.lang.Object value)
Converts the value to a json object and displays it nicely indented |
static java.lang.String
|
prettyPrint(java.lang.Object value, int indent)
Converts the value to a json object and displays it nicely indented |
static java.lang.Object
|
toJSON(java.lang.Object value)
Reverse method which converts a value into a json value |
static java.lang.Object
|
toList(JSONArray array)
Converts the json array into a list (recursive call). |
static java.lang.Object
|
toMap(JSONObject json)
Converts a json object into a map (recursive call). |
static java.lang.Object
|
toValue(java.lang.Object value)
Converts the value into its non JSON counter part: if the value is a org.json.JSONObject or a org.json.JSONArray then it will call the appropriate method, otherwise simply return the value. |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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() |
Method Detail |
---|
static java.lang.Object collectionToJSON(java.util.Collection list)
static java.lang.Object fromJSON(java.lang.String json)
toValue(new JSONObject(json))
or toValue(new JSONArray(json)
depending on if the json starts with [
or {
(with proper null
handling).
static java.lang.Object mapToJSON(java.util.Map map)
static java.lang.String prettyPrint(java.lang.Object value)
static java.lang.String prettyPrint(java.lang.Object value, int indent)
static java.lang.Object toJSON(java.lang.Object value)
static java.lang.Object toList(JSONArray array)
static java.lang.Object toMap(JSONObject json)
static java.lang.Object toValue(java.lang.Object value)
Groovy Documentation