|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sag.osami.contextstore.serialization.json.JSONSerializer
public class JSONSerializer
This serializing utility class uses the Jackson JSON-processor library, which is insanely fast and equally easy to use.
Yet there are a few restrictions regarding the classes of the data to be serialized:
private
is okay)Map
are used -- then, sensible default types are used during deserialization. Your classes don't have to implement the Serializable
interface. Those
kinds of data which are not particularly suited for JSON (e.g. huge byte[]
arrays) are handled (space-)efficiently.
Please note, that Jackson is not embedded in this bundle but must be present as an own bundle.
See the Jackson download page for
officially packaged OSGi bundles. Both jackson-core
and jackson-mapper
are necessary.
OSGi notice: In order to be able to deserialize all kinds of data, this bundle uses a wildcard Dynamic-Import
.
Constructor Summary | |
---|---|
JSONSerializer()
|
Method Summary | |
---|---|
java.lang.Object |
deserialize(java.lang.String[] sobj)
Deserializes the given data. |
static org.codehaus.jackson.map.ObjectMapper |
getJSON()
Returns the internally used instance of the Jackson ObjectMapper for re-use since creation of ObjectMappers can be considered as costly. |
java.lang.String[] |
serialize(java.lang.Object obj)
Serializes the given object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSONSerializer()
Method Detail |
---|
public static org.codehaus.jackson.map.ObjectMapper getJSON()
ObjectMapper
for re-use since creation of ObjectMappers can be considered as costly.
public java.lang.String[] serialize(java.lang.Object obj)
ISerializationHandler
serialize
in interface ISerializationHandler
obj
- object to be serializedpublic java.lang.Object deserialize(java.lang.String[] sobj)
ISerializationHandler
deserialize
in interface ISerializationHandler
sobj
- the serialized data as returned by the ISerializationHandler.serialize(Object)
method
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |