public class JacksonDataFormat
extends org.apache.camel.support.ServiceSupport
implements org.apache.camel.spi.DataFormat
Constructor and Description |
---|
JacksonDataFormat()
Use the default Jackson
ObjectMapper and Map |
JacksonDataFormat(Class<?> unmarshalType)
Use the default Jackson
ObjectMapper and with a custom
unmarshal type |
JacksonDataFormat(Class<?> unmarshalType,
Class<?> jsonView)
Use the default Jackson
ObjectMapper and with a custom
unmarshal type and JSON view |
JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> unmarshalType)
Use a custom Jackson mapper and and unmarshal type
|
JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper,
Class<?> unmarshalType,
Class<?> jsonView)
Use a custom Jackson mapper, unmarshal type and JSON view
|
Modifier and Type | Method and Description |
---|---|
protected void |
doStart() |
protected void |
doStop() |
Class<? extends Collection> |
getCollectionType() |
String |
getInclude() |
Class<?> |
getJsonView() |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
Class<?> |
getUnmarshalType() |
boolean |
isAllowJmsType() |
boolean |
isPrettyPrint() |
boolean |
isUseList() |
void |
marshal(org.apache.camel.Exchange exchange,
Object graph,
OutputStream stream) |
void |
setAllowJmsType(boolean allowJmsType)
Allows jackson to use the JMSType header as an indicator what the classname is for unmarshaling json content to POJO
By default this option is false.
|
void |
setCollectionType(Class<? extends Collection> collectionType) |
void |
setInclude(String include) |
void |
setJsonView(Class<?> jsonView) |
void |
setPrettyPrint(boolean prettyPrint) |
void |
setUnmarshalType(Class<?> unmarshalType) |
void |
setUseList(boolean useList) |
Object |
unmarshal(org.apache.camel.Exchange exchange,
InputStream stream) |
void |
useList()
Uses
ArrayList when unmarshalling. |
void |
useMap()
Uses
HashMap when unmarshalling. |
public JacksonDataFormat()
ObjectMapper
and Map
public JacksonDataFormat(Class<?> unmarshalType)
ObjectMapper
and with a custom
unmarshal typeunmarshalType
- the custom unmarshal typepublic JacksonDataFormat(Class<?> unmarshalType, Class<?> jsonView)
ObjectMapper
and with a custom
unmarshal type and JSON viewunmarshalType
- the custom unmarshal typejsonView
- marker class to specify properties to be included during marshalling.
See also http://wiki.fasterxml.com/JacksonJsonViewspublic JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType)
mapper
- the custom mapperunmarshalType
- the custom unmarshal typepublic JacksonDataFormat(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> unmarshalType, Class<?> jsonView)
mapper
- the custom mapperunmarshalType
- the custom unmarshal typejsonView
- marker class to specify properties to be included during marshalling.
See also http://wiki.fasterxml.com/JacksonJsonViewspublic void marshal(org.apache.camel.Exchange exchange, Object graph, OutputStream stream) throws Exception
marshal
in interface org.apache.camel.spi.DataFormat
Exception
public Object unmarshal(org.apache.camel.Exchange exchange, InputStream stream) throws Exception
unmarshal
in interface org.apache.camel.spi.DataFormat
Exception
public Class<?> getUnmarshalType()
public void setUnmarshalType(Class<?> unmarshalType)
public Class<? extends Collection> getCollectionType()
public void setCollectionType(Class<? extends Collection> collectionType)
public Class<?> getJsonView()
public void setJsonView(Class<?> jsonView)
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public String getInclude()
public void setInclude(String include)
public boolean isAllowJmsType()
public boolean isPrettyPrint()
public void setPrettyPrint(boolean prettyPrint)
public boolean isUseList()
public void setUseList(boolean useList)
public void useList()
ArrayList
when unmarshalling.public void useMap()
HashMap
when unmarshalling.public void setAllowJmsType(boolean allowJmsType)
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.ServiceSupport
Exception
Apache Camel