Serializer API
The serialization API is designed to be easily extensible by developers.
If you are writing your own serializer, you will typically subclass directly from either {@link org.apache.juneau.serializer.WriterSerializer}
or {@link org.apache.juneau.serializer.OutputStreamSerializer}.
The {@link org.apache.juneau.serializer.SerializerGroup} class represents a group of serializers registered with the media types they handle.
The SerializerGroup
class provides the following features:
Accept
header values.
Refer to {@link org.apache.juneau.serializer.SerializerGroup} for additional information.
Defining a new serializer is quite simple if you subclass directly from {@link org.apache.juneau.serializer.WriterSerializer}
or {@link org.apache.juneau.serializer.OutputStreamSerializer}.
In each case, you simply need to implement a single
method and specify a {@link org.apache.juneau.annotation.Produces} annotation.
The following example shows a simple serializer that converts images to output streams using standard JRE classes.
Serializer that take advantage of the entire {@link org.apache.juneau.CoreApi} interface to be able to serialize arbitrary beans and POJOs is
considerably more complex and outside the scope of this document.
If developing such a serializer, the best course of action would be to replicate what occurs in the {@link org.apache.juneau.json.JsonSerializer} class.