|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.json.JSONSerializer
public class JSONSerializer
Implementation of the Serializer
interface that reads data from
and writes data to a JavaScript Object Notation (JSON) file.
Field Summary | |
---|---|
static int |
BUFFER_SIZE
|
static String |
DEFAULT_CHARSET_NAME
|
static Type |
DEFAULT_TYPE
|
static String |
JSON_EXTENSION
|
static String |
MIME_TYPE
|
Constructor Summary | |
---|---|
JSONSerializer()
|
|
JSONSerializer(Charset charset)
|
|
JSONSerializer(Charset charset,
Type type)
|
|
JSONSerializer(Type type)
|
Method Summary | |
---|---|
boolean |
getAlwaysDelimitMapKeys()
Returns a flag indicating whether or not map keys will always be quote-delimited. |
Charset |
getCharset()
Returns the character set used to encode/decode the JSON data. |
ListenerList<JSONSerializerListener> |
getJSONSerializerListeners()
|
String |
getMIMEType(Object object)
Returns the MIME type of the data read and written by this serializer. |
Type |
getType()
Returns the type of the object that will be returned by readObject(Reader) . |
boolean |
isVerbose()
Returns the serializer's verbosity flag. |
static Object |
parse(String json)
Converts a JSON value to a Java object. |
static Boolean |
parseBoolean(String json)
Converts a JSON value to a boolean. |
static Double |
parseDouble(String json)
Converts a JSON value to a double. |
static Float |
parseFloat(String json)
Converts a JSON value to a float. |
static Integer |
parseInteger(String json)
Converts a JSON value to a integer. |
static List<?> |
parseList(String json)
Converts a JSON value to a list. |
static Long |
parseLong(String json)
Converts a JSON value to a long. |
static Map<String,?> |
parseMap(String json)
Converts a JSON value to a map. |
static Number |
parseNumber(String json)
Converts a JSON value to a number. |
static Short |
parseShort(String json)
Converts a JSON value to a short. |
static String |
parseString(String json)
Converts a JSON value to a string. |
Object |
readObject(InputStream inputStream)
Reads data from a JSON stream. |
Object |
readObject(Reader reader)
Reads data from a JSON stream. |
void |
setAlwaysDelimitMapKeys(boolean alwaysDelimitMapKeys)
Sets a flag indicating that map keys should always be quote-delimited. |
void |
setVerbose(boolean verbose)
Sets the serializer's verbosity flag. |
static String |
toString(Object value)
Converts a object to a JSON string representation. |
static String |
toString(Object value,
boolean alwaysDelimitMapKeys)
Converts a object to a JSON string representation. |
void |
writeObject(Object object,
OutputStream outputStream)
Writes data to a JSON stream. |
void |
writeObject(Object object,
Writer writer)
Writes data to a JSON stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_CHARSET_NAME
public static final Type DEFAULT_TYPE
public static final String JSON_EXTENSION
public static final String MIME_TYPE
public static final int BUFFER_SIZE
Constructor Detail |
---|
public JSONSerializer()
public JSONSerializer(Charset charset)
public JSONSerializer(Type type)
public JSONSerializer(Charset charset, Type type)
Method Detail |
---|
public Charset getCharset()
public Type getType()
readObject(Reader)
.
public boolean getAlwaysDelimitMapKeys()
public void setAlwaysDelimitMapKeys(boolean alwaysDelimitMapKeys)
alwaysDelimitMapKeys
- true to bound map keys in double quotes; false to
only quote-delimit keys as necessary.public boolean isVerbose()
public void setVerbose(boolean verbose)
verbose
- public Object readObject(InputStream inputStream) throws IOException, SerializationException
readObject
in interface Serializer<Object>
inputStream
- The input stream from which data will be read.
IOException
SerializationException
readObject(Reader)
public Object readObject(Reader reader) throws IOException, SerializationException
reader
- The reader from which data will be read.
getType()
:
IOException
SerializationException
public void writeObject(Object object, OutputStream outputStream) throws IOException, SerializationException
writeObject
in interface Serializer<Object>
object
- outputStream
- The output stream to which data will be written.
IOException
SerializationException
writeObject(Object, Writer)
public void writeObject(Object object, Writer writer) throws IOException, SerializationException
object
- The object to serialize. Must be one of the following types:
writer
- The writer to which data will be written.
IOException
SerializationException
public String getMIMEType(Object object)
Serializer
getMIMEType
in interface Serializer<Object>
object
- If provided, allows the serializer to attach parameters to the returned
MIME type containing more detailed information about the data. If
null, the base MIME type is returned.public static Object parse(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static String parseString(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Number parseNumber(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Short parseShort(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Integer parseInteger(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Long parseLong(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Float parseFloat(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Double parseDouble(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Boolean parseBoolean(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static List<?> parseList(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static Map<String,?> parseMap(String json) throws SerializationException
json
- The JSON value.
SerializationException
public static String toString(Object value) throws SerializationException
value
- The object to convert.
SerializationException
toString(Object, boolean)
public static String toString(Object value, boolean alwaysDelimitMapKeys) throws SerializationException
value
- The object to convert.alwaysDelimitMapKeys
- A flag indicating whether or not map keys will always be quote-delimited.
SerializationException
public ListenerList<JSONSerializerListener> getJSONSerializerListeners()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |