|
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.String
|
compactPrint(java.lang.Object value)
Represents the value in JSON, compact form (keys are not sorted) |
static java.lang.Object
|
fromJSON(java.lang.String json)
Given a json string, convert it to a value (map / list)
depending on if the json starts with |
static java.lang.Object
|
mapToJSON(java.util.Map map)
|
static ObjectMapper
|
newJacksonMapper(java.lang.Object sorting)
|
static java.lang.String
|
prettyPrint(java.lang.Object value)
Represents the value in JSON, nicely indented and human readable |
static java.lang.String
|
prettyPrint(java.lang.Object value, int indent)
Represents the value in JSON, nicely indented and human readable depending on 'indent' |
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.String compactPrint(java.lang.Object value)
static java.lang.Object fromJSON(java.lang.String json)
[
or {
(with proper null
handling).
static java.lang.Object mapToJSON(java.util.Map map)
static ObjectMapper newJacksonMapper(java.lang.Object sorting)
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