Skip to main content

Marshallers

Marshallers are simple pairings of a Serializer and Parser with convenience methods for serializing and parsing POJOs.

MarshallerT read(Object,Class<T>)CharMarshallerString write(Object)Csv Html Json OpenApi PlainText Json5 Uon UrlEncoding XmlStreamMarshallerbyte[] write(Object)MsgPack
Examples
// Using instance.
Json json = new Json();
MyPojo myPojo = json.read(string, MyPojo.class);
String string = json.write(myPojo);
// Using DEFAULT instance.
MyPojo myPojo = Json.DEFAULT.read(string, MyPojo.class);
String string = Json.DEFAULT.write(myPojo);

Juneau comes with the following predefined marshallers:

CsvHtmlJsonMsgPackOpenApiPlainTextJson5UonUrlEncodingXml

Each predefined marshaller also includes static convenience from/to methods to make it even easier to perform marshalling on POJOs:

JsonString of(Object)T to(Object,Class)
Examples
// Using shortcut static methods.
MyPojo myPojo = Json.to(jsonString, MyPojo.class);
String json = Json.of(myPojo);