com.endeca.infront.serialization
Class JsonSerializer
java.lang.Object
com.endeca.infront.serialization.JsonSerializer
public class JsonSerializer
- extends Object
A class for serializing java objects to JSON. The following objects can be serialized.
- Map (with String keys)
- List
- Number and its primitive equivalents
- Boolean and boolean
- Character and char
- String
- Java Bean
Circular references will throw an Exception.
The following rules apply.
- Map objects serialize to JSON objects.
- List objects serialize to JSON arrays.
- Java Beans serialize to JSON objects. The first first key, "@class", is the value of the class name of the java bean. The other keys are the names of properties of the bean.
Method Summary |
void |
write(Object pObject)
Serialize the given object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JsonSerializer
public JsonSerializer(Writer pWriter)
- Create a JsonSerializer with the given Writer.
- Parameters:
pWriter
- The writer to be used as a character stream
write
public void write(Object pObject)
throws IOException
- Serialize the given object.
- Parameters:
pObject
- The object to be serialized
- Throws:
IOException
- Any exception thrown by the underlying writer.
Copyright © 2012. All Rights Reserved.