public final class MarshallerHelper extends Object
MarshallerRegistry
.Modifier and Type | Method and Description |
---|---|
static <T> String |
listToJson(Class<T> elementType,
List<T> list,
RenderingContext ctx)
Convert the given list to json.
|
static <T> List<T> |
listToJson(Class<T> elementType,
String json,
RenderingContext ctx)
Read an object of the given type from given json.
|
static <T> T |
objectToJson(Class<T> type,
String json,
RenderingContext ctx)
Read an object of the given type from given json.
|
static <T> T |
objectToJson(Class<T> type,
Type genericType,
String json,
RenderingContext ctx)
Read an object of the given type from given json.
|
static <T> String |
objectToJson(T object,
RenderingContext ctx)
Convert the given object to json.
|
static <T> String |
objectToJson(Type genericType,
T object,
RenderingContext ctx)
Convert the given object to json.
|
public static <T> String objectToJson(T object, RenderingContext ctx) throws IOException
object
- The object to convert as json.ctx
- May be null - otherwise, use RenderingContext.CtxBuilder
to create the context.IOException
public static <T> String objectToJson(Type genericType, T object, RenderingContext ctx) throws IOException
Specify its generic type to be sure to get the best marshaller to manage it.
genericType
- The generic type of the object. You can easily create parametrize type using
TypeUtils#parameterize(Class, Type...)
object
- The object to convert as json.ctx
- May be null - otherwise, use RenderingContext.CtxBuilder
to create the context.IOException
public static <T> String listToJson(Class<T> elementType, List<T> list, RenderingContext ctx) throws IOException
Specify the list element type to get the best marshaller to manage conversion.
elementType
- The element type of the list.list
- The list to convert.ctx
- May be null - otherwise, use RenderingContext.CtxBuilder
to create the context.IOException
public static <T> T objectToJson(Class<T> type, String json, RenderingContext ctx) throws IOException
type
- The type of the read object.json
- The json to parse.ctx
- May be null - otherwise, use RenderingContext.CtxBuilder
to create the context.IOException
public static <T> T objectToJson(Class<T> type, Type genericType, String json, RenderingContext ctx) throws IOException
Specify its generic type to be sure to get the best marshaller to manage it.
type
- The type of the read object.genericType
- The generic type of the object. You can easily create parametrize type using
TypeUtils#parameterize(Class, Type...)
json
- The json to parse.ctx
- May be null - otherwise, use RenderingContext.CtxBuilder
to create the context.IOException
public static <T> List<T> listToJson(Class<T> elementType, String json, RenderingContext ctx) throws IOException
Specify the list element type to get the best marshaller to manage conversion.
elementType
- The element type of the list.json
- The json to parse.ctx
- May be null - otherwise, use RenderingContext.CtxBuilder
to create the context.IOException
Copyright © 2018 Nuxeo. All rights reserved.