|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.shindig.common.JsonSerializer
public final class JsonSerializer
Serializes a JSONObject. The methods here are designed to be substantially more CPU and memory efficient than those found in org.json or net.sf.json. In profiling, the performance of both of these libraries has been found to be woefully inadequate for large scale deployments. The append*() methods can be used to serialize directly into an Appendable, such as an output stream. This avoids unnecessary copies to intermediate objects. To reduce output size, null values in json arrays and objects will always be removed.
| Method Summary | |
|---|---|
static void |
append(Appendable buf,
Object value)
Appends a value to the buffer. |
static void |
appendArray(Appendable buf,
Object[] array)
Appends an array to the buffer. |
static void |
appendCollection(Appendable buf,
Collection<?> collection)
Appends a Collection to the buffer. |
static void |
appendJsonArray(Appendable buf,
org.json.JSONArray array)
Append a JSONArray to the buffer. |
static void |
appendJsonObject(Appendable buf,
org.json.JSONObject object)
Appends a JSONObject to the buffer. |
static void |
appendMap(Appendable buf,
Map<String,?> map)
Appends a Map to the buffer. |
static void |
appendMultimap(Appendable buf,
com.google.common.collect.Multimap<String,Object> map)
Appends a Map to the buffer. |
static void |
appendPojo(Appendable buf,
Object pojo)
Appends a java object using getters |
static void |
appendString(Appendable buf,
CharSequence string)
Appends a string to the buffer. |
static String |
serialize(Collection<?> collection)
Serializes a Collection as a JSON array. |
static String |
serialize(org.json.JSONArray array)
Serializes a JSON array. |
static String |
serialize(org.json.JSONObject object)
Serialize a JSONObject. |
static String |
serialize(Map<String,?> map)
Serializes a Map as a JSON object. |
static String |
serialize(Object object)
|
static String |
serialize(Object[] array)
Serializes an array as a JSON array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String serialize(Object object)
public static String serialize(org.json.JSONObject object)
public static String serialize(Map<String,?> map)
public static String serialize(Collection<?> collection)
public static String serialize(Object[] array)
public static String serialize(org.json.JSONArray array)
public static void append(Appendable buf,
Object value)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendPojo(Appendable buf,
Object pojo)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendArray(Appendable buf,
Object[] array)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendJsonArray(Appendable buf,
org.json.JSONArray array)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendCollection(Appendable buf,
Collection<?> collection)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendMap(Appendable buf,
Map<String,?> map)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendMultimap(Appendable buf,
com.google.common.collect.Multimap<String,Object> map)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendJsonObject(Appendable buf,
org.json.JSONObject object)
throws IOException
IOException - If Appendable.append(char) throws an exception.
public static void appendString(Appendable buf,
CharSequence string)
throws IOException
IOException - If Appendable.append(char) throws an exception.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||