Skip to main content

Converters

Converters can be thought of as "post-processors" for response POJOs before they get passed to the serializer.

Converters are associated with resource classes and methods via the following:

RestconvertersRestOpconverters
Example
// GET person request handler.
// Traversable conversion enabled to allow nodes in returned POJO tree to be addressed.
// Queryable conversion enabled to allow returned POJO to be searched/viewed/sorted.
@RestGet(
path="/people/{id}/*",
converters={Traversable.class,Queryable.class}
)
public Person getPerson(@Path("id") int id) {
return findPerson(id);
}

Juneau defines the following converters out-of-the-box:

RestConverterQueryable - Provides query parameters that can be used to transform the response (i.e. search/view/sort the POJO response before being serialized).Traversable - Allows nodes in the POJO response tree to be individually accessed through additional path info on the request.Introspectable - Allows method calls to be made on the response POJO, and for the result of that method call to be serialized as the response.