|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.alfresco.json.JSONUtil
public class JSONUtil
Utilities for JSON-parsing.
| Field Summary | |
|---|---|
static String |
FORM_PROCESSOR_JSON_PERSISTED_OBJECT
|
static String |
HEADER_ACCEPT
|
static String |
HEADER_CONTENT_TYPE
|
static String |
JSON_DATA
|
static String |
JSON_ID
|
static String |
JSON_ITEMS
|
static String |
JSON_NAME
|
static String |
MIME_TYPE_JSON
|
| Constructor Summary | |
|---|---|
JSONUtil()
|
|
| Method Summary | |
|---|---|
static org.json.simple.JSONArray |
getArray(org.json.simple.JSONObject json,
String key)
|
static org.json.simple.JSONArray |
getDataArrayFromResponse(org.apache.http.HttpEntity method)
Extract the "data" JSON-array from the method's response. |
static org.json.simple.JSONObject |
getDataFromResponse(org.apache.http.HttpEntity method)
Extract the "data" JSON-object from the method's response. |
static org.json.simple.JSONObject |
getObject(org.json.simple.JSONObject json,
String key)
|
static String |
getString(org.json.simple.JSONObject json,
String key,
String defaultValue)
Gets a string-value from the given JSON-object for the given key. |
static void |
populateRequestBody(org.apache.http.client.methods.HttpPost method,
org.json.simple.JSONObject object)
Adds the JSON as request-body the the method and sets the correct content-type. |
static org.json.simple.JSONObject |
readStream(org.apache.http.HttpEntity entity)
Parses http response stream into a JSONObject. |
static void |
setJSONExpected(org.apache.http.client.methods.HttpPost method)
Sets a header to notify server we expect a JSON-repsponse for this method. |
static org.apache.http.entity.StringEntity |
setMessageBody(org.json.simple.JSONObject json)
Populate HTTP message call with given content. |
static org.apache.http.entity.StringEntity |
setMessageBody(String content)
Populate HTTP message call with given content. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String JSON_DATA
public static final String JSON_ID
public static final String JSON_ITEMS
public static final String JSON_NAME
public static final String FORM_PROCESSOR_JSON_PERSISTED_OBJECT
public static final String MIME_TYPE_JSON
public static final String HEADER_ACCEPT
public static final String HEADER_CONTENT_TYPE
| Constructor Detail |
|---|
public JSONUtil()
| Method Detail |
|---|
public static void setJSONExpected(org.apache.http.client.methods.HttpPost method)
method -
public static void populateRequestBody(org.apache.http.client.methods.HttpPost method,
org.json.simple.JSONObject object)
method - object - public static org.json.simple.JSONObject getDataFromResponse(org.apache.http.HttpEntity method)
method - the method containing the response
public static org.json.simple.JSONArray getDataArrayFromResponse(org.apache.http.HttpEntity method)
method - the method containing the response
public static String getString(org.json.simple.JSONObject json,
String key,
String defaultValue)
json - the json objectkey - key pointing to the valuedefaultValue - if value is not set or if value is not of type
"String", this value is returned
public static org.json.simple.JSONArray getArray(org.json.simple.JSONObject json,
String key)
json - JSON to extract array fromkey - key under which array is present on JSON
JSONArray. Returns null, if the value is null or not
an array.
public static org.json.simple.JSONObject getObject(org.json.simple.JSONObject json,
String key)
json - JSON to extract object fromkey - key under which object is present on JSON
JSONObject. Returns null, if the value is null or not
an object.
public static org.apache.http.entity.StringEntity setMessageBody(String content)
throws UnsupportedEncodingException
content - String content
StringEntity content.
UnsupportedEncodingException - if unsupported
public static org.apache.http.entity.StringEntity setMessageBody(org.json.simple.JSONObject json)
throws UnsupportedEncodingException
json - JSONObject content
StringEntity content.
UnsupportedEncodingException - if unsupportedpublic static org.json.simple.JSONObject readStream(org.apache.http.HttpEntity entity)
JSONObject.
stream - Http response entity
JSONObject response
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||