public final class MarshallerHelper extends Object
MarshallerRegistry.| Modifier and Type | Method and Description | 
|---|---|
static <T> List<T> | 
jsonToList(Class<T> elementType,
          String json,
          RenderingContext ctx)  | 
static <T> T | 
jsonToObject(Class<T> type,
            String json,
            RenderingContext ctx)  | 
static <T> T | 
jsonToObject(Class<T> type,
            Type genericType,
            String json,
            RenderingContext ctx)  | 
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)
Deprecated. 
 
since 10.2, use  
jsonToList(Class, String, RenderingContext) instead. | 
static <T> T | 
objectToJson(Class<T> type,
            String json,
            RenderingContext ctx)
Deprecated. 
 
since 10.2 use  
jsonToObject(Class, String, RenderingContext) instead. | 
static <T> T | 
objectToJson(Class<T> type,
            Type genericType,
            String json,
            RenderingContext ctx)
Deprecated. 
 
since 10.2, use  
jsonToObject(Class, Type, String, RenderingContext) instead. | 
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.IOExceptionpublic 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.IOExceptionpublic 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@Deprecated public static <T> T objectToJson(Class<T> type, String json, RenderingContext ctx) throws IOException
jsonToObject(Class, String, RenderingContext) instead.type - The type of the read object.json - The json to parse.ctx - May be null - otherwise, use RenderingContext.CtxBuilder to create the context.IOExceptionpublic static <T> T jsonToObject(Class<T> type, String json, RenderingContext ctx) throws IOException
IOException@Deprecated public static <T> T objectToJson(Class<T> type, Type genericType, String json, RenderingContext ctx) throws IOException
jsonToObject(Class, Type, String, RenderingContext) instead.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.IOExceptionpublic static <T> T jsonToObject(Class<T> type, Type genericType, String json, RenderingContext ctx) throws IOException
IOException@Deprecated public static <T> List<T> listToJson(Class<T> elementType, String json, RenderingContext ctx) throws IOException
jsonToList(Class, String, RenderingContext) instead.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.IOExceptionpublic static <T> List<T> jsonToList(Class<T> elementType, String json, RenderingContext ctx) throws IOException
IOExceptionCopyright © 2019 Nuxeo. All rights reserved.