Class JsonDataFormat.Builder
- java.lang.Object
-
- org.apache.camel.model.dataformat.JsonDataFormat.Builder
-
- All Implemented Interfaces:
DataFormatBuilder<JsonDataFormat>
- Enclosing class:
- JsonDataFormat
public static class JsonDataFormat.Builder extends Object implements DataFormatBuilder<JsonDataFormat>
Builder
is a specific builder forJsonDataFormat
.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonDataFormat.Builder
allowJmsType(boolean allowJmsType)
Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to unmarshal to.JsonDataFormat.Builder
allowJmsType(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.JsonDataFormat.Builder
allowUnmarshallType(boolean allowUnmarshallType)
If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling.JsonDataFormat.Builder
allowUnmarshallType(String allowUnmarshallType)
If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling.JsonDataFormat.Builder
autoDiscoverObjectMapper(boolean autoDiscoverObjectMapper)
If set to true then Jackson will look for an objectMapper to use from the registryJsonDataFormat.Builder
autoDiscoverObjectMapper(String autoDiscoverObjectMapper)
If set to true then Jackson will look for an objectMapper to use from the registryJsonDataFormat.Builder
autoDiscoverSchemaResolver(boolean autoDiscoverSchemaResolver)
When not disabled, the SchemaResolver will be looked up into the registryJsonDataFormat.Builder
autoDiscoverSchemaResolver(String autoDiscoverSchemaResolver)
When not disabled, the SchemaResolver will be looked up into the registryJsonDataFormat.Builder
collectionType(Class<?> collectionType)
JsonDataFormat.Builder
collectionTypeName(String collectionTypeName)
Refers to a custom collection type to lookup in the registry to use.JsonDataFormat.Builder
contentTypeHeader(boolean contentTypeHeader)
JsonDataFormat.Builder
contentTypeHeader(String contentTypeHeader)
JsonDataFormat.Builder
disableFeatures(String disableFeatures)
Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper.JsonDataFormat.Builder
dropRootNode(boolean dropRootNode)
Whether XStream will drop the root node in the generated JSon.JsonDataFormat.Builder
dropRootNode(String dropRootNode)
Whether XStream will drop the root node in the generated JSon.JsonDataFormat.Builder
enableFeatures(String enableFeatures)
Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper.JsonDataFormat
end()
Ends the build of the data format.JsonDataFormat.Builder
include(String include)
If you want to marshal a pojo to JSON, and the pojo has some fields with null values.JsonDataFormat.Builder
jsonView(Class<?> jsonView)
When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output.JsonDataFormat.Builder
jsonViewTypeName(String jsonViewTypeName)
When marshalling a POJO to JSON you might want to exclude certain fields from the JSON output.JsonDataFormat.Builder
library(JsonLibrary library)
Which json library to use.JsonDataFormat.Builder
moduleClassNames(String moduleClassNames)
To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class names.JsonDataFormat.Builder
moduleRefs(String moduleRefs)
To use custom Jackson modules referred from the Camel registry.JsonDataFormat.Builder
namingStrategy(String namingStrategy)
If set then Jackson will use the the defined Property Naming Strategy.JsonDataFormat.Builder
objectMapper(String objectMapper)
Lookup and use the existing ObjectMapper with the given id when using Jackson.JsonDataFormat.Builder
permissions(Class<?>... type)
To add permission for the given pojo classes.JsonDataFormat.Builder
permissions(String permissions)
Adds permissions that controls which Java packages and classes XStream is allowed to use during unmarshal from xml/json to Java beans.JsonDataFormat.Builder
prettyPrint(boolean prettyPrint)
To enable pretty printing output nicely formatted.JsonDataFormat.Builder
prettyPrint(String prettyPrint)
To enable pretty printing output nicely formatted.JsonDataFormat.Builder
schemaResolver(String schemaResolver)
Optional schema resolver used to lookup schemas for the data in transit.JsonDataFormat.Builder
timezone(String timezone)
If set then Jackson will use the Timezone when marshalling/unmarshalling.JsonDataFormat.Builder
unmarshalType(Class<?> unmarshalType)
Class of the java type to use when unmarshallingJsonDataFormat.Builder
unmarshalTypeName(String unmarshalTypeName)
Class name of the java type to use when unmarshallingJsonDataFormat.Builder
useDefaultObjectMapper(boolean useDefaultObjectMapper)
Whether to lookup and use default Jackson ObjectMapper from the registry.JsonDataFormat.Builder
useDefaultObjectMapper(String useDefaultObjectMapper)
Whether to lookup and use default Jackson ObjectMapper from the registry.JsonDataFormat.Builder
useList(boolean useList)
To unmarshal to a List of Map or a List of Pojo.JsonDataFormat.Builder
useList(String useList)
To unmarshal to a List of Map or a List of Pojo.
-
-
-
Method Detail
-
contentTypeHeader
public JsonDataFormat.Builder contentTypeHeader(String contentTypeHeader)
-
contentTypeHeader
public JsonDataFormat.Builder contentTypeHeader(boolean contentTypeHeader)
-
objectMapper
public JsonDataFormat.Builder objectMapper(String objectMapper)
Lookup and use the existing ObjectMapper with the given id when using Jackson.
-
useDefaultObjectMapper
public JsonDataFormat.Builder useDefaultObjectMapper(String useDefaultObjectMapper)
Whether to lookup and use default Jackson ObjectMapper from the registry.
-
useDefaultObjectMapper
public JsonDataFormat.Builder useDefaultObjectMapper(boolean useDefaultObjectMapper)
Whether to lookup and use default Jackson ObjectMapper from the registry.
-
prettyPrint
public JsonDataFormat.Builder prettyPrint(String prettyPrint)
To enable pretty printing output nicely formatted. Is by default false.
-
prettyPrint
public JsonDataFormat.Builder prettyPrint(boolean prettyPrint)
To enable pretty printing output nicely formatted. Is by default false.
-
unmarshalTypeName
public JsonDataFormat.Builder unmarshalTypeName(String unmarshalTypeName)
Class name of the java type to use when unmarshalling
-
unmarshalType
public JsonDataFormat.Builder unmarshalType(Class<?> unmarshalType)
Class of the java type to use when unmarshalling
-
library
public JsonDataFormat.Builder library(JsonLibrary library)
Which json library to use.
-
jsonViewTypeName
public JsonDataFormat.Builder jsonViewTypeName(String jsonViewTypeName)
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
-
jsonView
public JsonDataFormat.Builder jsonView(Class<?> jsonView)
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
-
include
public JsonDataFormat.Builder include(String include)
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
-
allowJmsType
public JsonDataFormat.Builder allowJmsType(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.
-
allowJmsType
public JsonDataFormat.Builder allowJmsType(boolean allowJmsType)
Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to unmarshal to.
-
collectionTypeName
public JsonDataFormat.Builder collectionTypeName(String collectionTypeName)
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.
-
collectionType
public JsonDataFormat.Builder collectionType(Class<?> collectionType)
-
useList
public JsonDataFormat.Builder useList(String useList)
To unmarshal to a List of Map or a List of Pojo.
-
useList
public JsonDataFormat.Builder useList(boolean useList)
To unmarshal to a List of Map or a List of Pojo.
-
moduleClassNames
public JsonDataFormat.Builder moduleClassNames(String moduleClassNames)
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.
-
moduleRefs
public JsonDataFormat.Builder moduleRefs(String moduleRefs)
To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma.
-
enableFeatures
public JsonDataFormat.Builder enableFeatures(String enableFeatures)
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
-
disableFeatures
public JsonDataFormat.Builder disableFeatures(String disableFeatures)
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
-
permissions
public JsonDataFormat.Builder permissions(String permissions)
Adds permissions that controls which Java packages and classes XStream is allowed to use during unmarshal from xml/json to Java beans. A permission must be configured either here or globally using a JVM system property. The permission can be specified in a syntax where a plus sign is allow, and minus sign is deny.
Wildcards is supported by using .* as prefix. For example to allow com.foo and all subpackages then specfy +com.foo.*. Multiple permissions can be configured separated by comma, such as +com.foo.*,-com.foo.bar.MySecretBean.
The following default permission is always included: "-*,java.lang.*,java.util.*" unless its overridden by specifying a JVM system property with they key org.apache.camel.xstream.permissions.
-
permissions
public JsonDataFormat.Builder permissions(Class<?>... type)
To add permission for the given pojo classes.- Parameters:
type
- the pojo class(es) xstream should use as allowed permission- See Also:
JsonDataFormat.setPermissions(String)
-
allowUnmarshallType
public JsonDataFormat.Builder allowUnmarshallType(String allowUnmarshallType)
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.
-
allowUnmarshallType
public JsonDataFormat.Builder allowUnmarshallType(boolean allowUnmarshallType)
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.
-
timezone
public JsonDataFormat.Builder timezone(String timezone)
If set then Jackson will use the Timezone when marshalling/unmarshalling. This option will have no effect on the others Json DataFormat, like gson, fastjson and xstream.
-
autoDiscoverObjectMapper
public JsonDataFormat.Builder autoDiscoverObjectMapper(String autoDiscoverObjectMapper)
If set to true then Jackson will look for an objectMapper to use from the registry
-
autoDiscoverObjectMapper
public JsonDataFormat.Builder autoDiscoverObjectMapper(boolean autoDiscoverObjectMapper)
If set to true then Jackson will look for an objectMapper to use from the registry
-
dropRootNode
public JsonDataFormat.Builder dropRootNode(String dropRootNode)
Whether XStream will drop the root node in the generated JSon. You may want to enable this when using POJOs; as then the written object will include the class name as root node, which is often not intended to be written in the JSON output.
-
dropRootNode
public JsonDataFormat.Builder dropRootNode(boolean dropRootNode)
Whether XStream will drop the root node in the generated JSon. You may want to enable this when using POJOs; as then the written object will include the class name as root node, which is often not intended to be written in the JSON output.
-
schemaResolver
public JsonDataFormat.Builder schemaResolver(String schemaResolver)
Optional schema resolver used to lookup schemas for the data in transit.
-
autoDiscoverSchemaResolver
public JsonDataFormat.Builder autoDiscoverSchemaResolver(String autoDiscoverSchemaResolver)
When not disabled, the SchemaResolver will be looked up into the registry
-
autoDiscoverSchemaResolver
public JsonDataFormat.Builder autoDiscoverSchemaResolver(boolean autoDiscoverSchemaResolver)
When not disabled, the SchemaResolver will be looked up into the registry
-
namingStrategy
public JsonDataFormat.Builder namingStrategy(String namingStrategy)
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
-
end
public JsonDataFormat end()
Description copied from interface:DataFormatBuilder
Ends the build of the data format.- Specified by:
end
in interfaceDataFormatBuilder<JsonDataFormat>
- Returns:
- the data format fully built.
-
-