|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pfsw.text.json.JsonUtil
public class JsonUtil
Convenience methods for JavaScript Object Notation (JSON) handling. JSON Web Site
| Field Summary | |
|---|---|
static JsonUtil |
JU
The singleton of this class (i.e. |
| Constructor Summary | |
|---|---|
protected |
JsonUtil()
|
| Method Summary | |
|---|---|
void |
appendJSONArray(java.lang.Appendable output,
java.lang.Object... objects)
Appends the given object array to the given output in a valid JSON string representation. |
void |
appendJSONConvertible(java.lang.Appendable output,
org.pfsw.bif.text.IJSONConvertible jsonConvertible)
Converts the given object to a valid JSON string representation and appends it to the given buffer. |
void |
appendJSONMap(java.lang.Appendable output,
java.util.Map<java.lang.String,java.lang.Object> map)
Adds the given map to the buffer as JSON representation. |
void |
appendJSONObject(java.lang.Appendable output,
java.lang.Object object)
Appends the given object to the output as a valid JSON string. |
void |
appendJsonPair(java.lang.Appendable output,
java.lang.String name,
java.lang.Object value)
Appends the given name and value as JSON pair member to the given buffer. |
void |
appendJSONPair(java.lang.Appendable output,
java.lang.String name,
java.lang.Object value)
Appends the given name and value as JSON pair member to the given buffer. |
void |
appendJsonPair(java.lang.Appendable output,
java.lang.String name,
java.lang.Object value,
boolean compact)
Appends the given name and value as JSON pair member to the given output. |
void |
appendJSONString(java.lang.Appendable output,
java.lang.String str)
Appends the given string to the buffer as a valid JSON string literal. |
java.lang.String |
arrayToJSON(java.lang.Object... objects)
Converts the given object array to a valid JSON string representation. |
java.lang.String |
convertToJSON(org.pfsw.bif.text.IJSONConvertible jsonConvertible)
Converts the given object to a valid JSON string representation. |
static JsonUtil |
current()
Returns the only instance this class supports (design pattern "Singleton") |
boolean |
isValidJsonType(java.lang.Class<?> type)
Returns true if the given class one of the supported JSON object types. |
boolean |
isValidJsonTypeInstance(java.lang.Object object)
Returns true if the given object is null or an instance of one of the supported JSON object types. |
java.lang.String |
mapToJSON(java.util.Map<java.lang.String,java.lang.Object> map)
Converts the given map to a valid JSON string representation. |
java.lang.String |
objectToJSONValue(java.lang.Object object)
Tries to convert the given object to a JSON string. |
java.lang.String |
toJSONStringLiteral(java.lang.String str)
Returns the given string as JSON string literal (i.e. enclosed in quotes). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final JsonUtil JU
| Constructor Detail |
|---|
protected JsonUtil()
| Method Detail |
|---|
public static JsonUtil current()
public java.lang.String convertToJSON(org.pfsw.bif.text.IJSONConvertible jsonConvertible)
jsonConvertible - The object to convert.
public java.lang.String arrayToJSON(java.lang.Object... objects)
objects - The object array to convert.
public java.lang.String mapToJSON(java.util.Map<java.lang.String,java.lang.Object> map)
map - The map to convert.
public java.lang.String toJSONStringLiteral(java.lang.String str)
str - The string to make JSON compatible (might by null)
public void appendJSONPair(java.lang.Appendable output,
java.lang.String name,
java.lang.Object value)
output - The buffer to append to.name - The name of the pair.value - The value of the pair.
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.
public void appendJsonPair(java.lang.Appendable output,
java.lang.String name,
java.lang.Object value)
output - The buffer to append to.name - The name of the pair.value - The value of the pair.
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.
public void appendJsonPair(java.lang.Appendable output,
java.lang.String name,
java.lang.Object value,
boolean compact)
output - The buffer to append to.name - The name of the pair.value - The value of the pair.compact - if true, no spaces are inserted between name and separator and separator and value.
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.
public void appendJSONString(java.lang.Appendable output,
java.lang.String str)
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.
public void appendJSONConvertible(java.lang.Appendable output,
org.pfsw.bif.text.IJSONConvertible jsonConvertible)
jsonConvertible - The object to convert and append.
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.
public void appendJSONArray(java.lang.Appendable output,
java.lang.Object... objects)
objects - The object array to append.
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.
public void appendJSONObject(java.lang.Appendable output,
java.lang.Object object)
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.
public void appendJSONMap(java.lang.Appendable output,
java.util.Map<java.lang.String,java.lang.Object> map)
org.pfsw.bif.exceptions.IORuntimeException - if the given output object throws an IOException.public java.lang.String objectToJSONValue(java.lang.Object object)
object - Any object (even null).
public boolean isValidJsonTypeInstance(java.lang.Object object)
Valid types are:
public boolean isValidJsonType(java.lang.Class<?> type)
Valid types are:
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||