Class JsonDataFormat
java.lang.Object
org.apache.camel.model.IdentifiedType
org.apache.camel.model.DataFormatDefinition
org.apache.camel.model.dataformat.JsonDataFormat
- All Implemented Interfaces:
ContentTypeHeaderAware
@Metadata(label="dataformat,transformation,json",
title="JSon")
public class JsonDataFormat
extends DataFormatDefinition
implements ContentTypeHeaderAware
Marshal POJOs to JSON and back.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowJmsType
(boolean allowJmsType) allowJmsType
(String allowJmsType) allowUnmarshallType
(boolean allowUnmarshallType) allowUnmarshallType
(String allowUnmarshallType) autoDiscoverObjectMapper
(boolean autoDiscoverObjectMapper) autoDiscoverObjectMapper
(String autoDiscoverObjectMapper) collectionType
(Class<?> collectionType) collectionType
(String collectionType) disableFeatures
(String disableFeatures) enableFeatures
(String enableFeatures) Class<?>
Whether the data format should set the Content-Type header with the type from the data format.Class<?>
Class<?>
library
(JsonLibrary library) moduleClassNames
(String moduleClassNames) moduleRefs
(String moduleRefs) namingStrategy
(String namingStrategy) objectMapper
(String objectMapper) prettyPrint
(boolean prettyPrint) prettyPrint
(String prettyPrint) void
setAllowJmsType
(String allowJmsType) Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to unmarshal to.void
setAllowUnmarshallType
(String allowUnmarshallType) If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling.void
setAutoDiscoverObjectMapper
(String autoDiscoverObjectMapper) If set to true then Jackson will look for an objectMapper to use from the registryvoid
setAutoDiscoverSchemaResolver
(String autoDiscoverSchemaResolver) When not disabled, the SchemaResolver will be looked up into the registryvoid
setCollectionType
(Class<?> collectionType) void
setCollectionTypeName
(String collectionTypeName) Refers to a custom collection type to lookup in the registry to use.void
setContentTypeHeader
(String contentTypeHeader) Whether the data format should set the Content-Type header with the type from the data format.void
setDateFormatPattern
(String dateFormatPattern) void
setDisableFeatures
(String disableFeatures) Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper.void
setEnableFeatures
(String enableFeatures) Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper.void
setInclude
(String include) If you want to marshal a pojo to JSON, and the pojo has some fields with null values.void
setJsonView
(Class<?> jsonView) When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output.void
setJsonViewTypeName
(String jsonViewTypeName) When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output.void
setLibrary
(JsonLibrary library) Which json library to use.void
setModuleClassNames
(String moduleClassNames) To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class names.void
setModuleRefs
(String moduleRefs) To use custom Jackson modules referred from the Camel registry.void
setNamingStrategy
(String namingStrategy) If set then Jackson will use the the defined Property Naming Strategy.void
setObjectMapper
(String objectMapper) Lookup and use the existing ObjectMapper with the given id when using Jackson.void
setPrettyPrint
(String prettyPrint) To enable pretty printing output nicely formatted.void
setSchemaResolver
(String schemaResolver) Optional schema resolver used to lookup schemas for the data in transit.void
setTimezone
(String timezone) If set then Jackson will use the Timezone when marshalling/unmarshalling.void
setUnmarshalType
(Class<?> unmarshalType) Class of the java type to use when unmarshallingvoid
setUnmarshalTypeName
(String unmarshalTypeName) Class name of the java type to use when unmarshallingvoid
setUseDefaultObjectMapper
(String useDefaultObjectMapper) Whether to lookup and use default Jackson ObjectMapper from the registry.void
setUseList
(String useList) To unmarshal to a List of Map or a List of Pojo.unmarshalType
(Class<?> unmarshalType) unmarshalType
(String unmarshalType) useDefaultObjectMapper
(boolean useDefaultObjectMapper) useDefaultObjectMapper
(String useDefaultObjectMapper) useList
(boolean useList) Methods inherited from class org.apache.camel.model.DataFormatDefinition
getDataFormat, getShortName, setDataFormat, setDataFormatName
Methods inherited from class org.apache.camel.model.IdentifiedType
getId, setId
-
Constructor Details
-
JsonDataFormat
public JsonDataFormat() -
JsonDataFormat
-
-
Method Details
-
getDataFormatName
- Overrides:
getDataFormatName
in classDataFormatDefinition
-
getContentTypeHeader
Description copied from interface:ContentTypeHeaderAware
Whether the data format should set the Content-Type header with the type from the data format. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.- Specified by:
getContentTypeHeader
in interfaceContentTypeHeaderAware
-
setContentTypeHeader
Description copied from interface:ContentTypeHeaderAware
Whether the data format should set the Content-Type header with the type from the data format. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc.- Specified by:
setContentTypeHeader
in interfaceContentTypeHeaderAware
-
getDateFormatPattern
-
setDateFormatPattern
-
getObjectMapper
-
setObjectMapper
Lookup and use the existing ObjectMapper with the given id when using Jackson. -
getUseDefaultObjectMapper
-
setUseDefaultObjectMapper
Whether to lookup and use default Jackson ObjectMapper from the registry. -
getPrettyPrint
-
setPrettyPrint
To enable pretty printing output nicely formatted. Is by default false. -
getUnmarshalTypeName
-
setUnmarshalTypeName
Class name of the java type to use when unmarshalling -
getUnmarshalType
-
setUnmarshalType
Class of the java type to use when unmarshalling -
getLibrary
-
setLibrary
Which json library to use. -
getJsonViewTypeName
-
setJsonViewTypeName
When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView annotations -
getJsonView
-
setJsonView
When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output. With Jackson you can use JSON views to accomplish this. This option is to refer to the class which has @JsonView annotations -
getInclude
-
setInclude
If you want to marshal a pojo to JSON, and the pojo has some fields with null values. And you want to skip these null values, you can set this option to NON_NULL -
getAllowJmsType
-
setAllowJmsType
Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to unmarshal to. -
getCollectionTypeName
-
setCollectionTypeName
Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but allows using different collection types than java.util.Collection based as default. -
getCollectionType
-
setCollectionType
-
getUseList
-
setUseList
To unmarshal to a List of Map or a List of Pojo. -
getModuleClassNames
-
setModuleClassNames
To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class names. Multiple classes can be separated by comma. -
getModuleRefs
-
setModuleRefs
To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma. -
getEnableFeatures
-
setEnableFeatures
Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma -
getDisableFeatures
-
setDisableFeatures
Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma -
getAllowUnmarshallType
-
setAllowUnmarshallType
If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. This should only be enabled when desired to be used. -
getTimezone
-
setTimezone
If set then Jackson will use the Timezone when marshalling/unmarshalling. This option will have no effect on the others Json DataFormat, like gson and fastjson. -
getAutoDiscoverObjectMapper
-
setAutoDiscoverObjectMapper
If set to true then Jackson will look for an objectMapper to use from the registry -
setSchemaResolver
Optional schema resolver used to lookup schemas for the data in transit. -
getSchemaResolver
-
getAutoDiscoverSchemaResolver
-
setAutoDiscoverSchemaResolver
When not disabled, the SchemaResolver will be looked up into the registry -
getNamingStrategy
-
setNamingStrategy
If set then Jackson will use the the defined Property Naming Strategy. Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE -
objectMapper
-
useDefaultObjectMapper
-
useDefaultObjectMapper
-
prettyPrint
-
prettyPrint
-
library
-
unmarshalType
-
unmarshalType
-
jsonView
-
include
-
allowJmsType
-
allowJmsType
-
collectionType
-
collectionType
-
useList
-
useList
-
moduleClassNames
-
moduleRefs
-
enableFeatures
-
disableFeatures
-
allowUnmarshallType
-
allowUnmarshallType
-
timezone
-
autoDiscoverObjectMapper
-
autoDiscoverObjectMapper
-
namingStrategy
-