Conversion by Properties (Deprecated)

Conversion by Properties is a deprecated configuration form of inboundTransformationStrategy. It sets properties directly on the strategy, and the conversion depends on those properties and the incoming payload type. Use Conversion by Format for new integration flows. See Payload Types for the payload representations.

You can’t mix conversion by properties and conversion by format in the same strategy. A strategy that mixes the two formats fails when the flow spec is built.

Set objectConversionFormat to a format such as MarshallingFormat.JSON and characterSet to a character encoding:

inboundTransformationStrategy {
    objectConversionFormat = <marshalling format>
    characterSet = <character encoding>
}
Refer to Oracle’s Internationalization Guide for a list of supported characterSet encodings.

The following example configures a map processor that receives JSON text with a results property:

map {
    id = "format-response"
    mapSpec = """
        {
            "message" : #input.payload.results[[1]]
        }
    """.trimIndent()
    inboundTransformationStrategy {
        objectConversionFormat = MarshallingFormat.JSON
    }
}

If you set both objectConversionFormat and characterSet, the same property-based strategy can convert in either direction. For binary input, it produces an object; for object input, it produces a string. A Conversion by Format strategy converts in one direction, so there is no single replacement. Replace such a strategy with fromJsonText() or fromXmlText() where the payload arrives as binary or a string. Use fromJsonCompliant() where it arrives as an object.

The following table shows the properties for each conversion and the Conversion by Format strategy that replaces them:

From To Conversion by properties Conversion by format

String

Object

objectConversionFormat = MarshallingFormat.JSON
fromJsonText().toJsonCompliant()

String

XML compliant object

objectConversionFormat = MarshallingFormat.XML
fromXmlText().toJsonCompliant()

Binary XML

XML compliant object

objectConversionFormat = MarshallingFormat.XML
characterSet = "ISO-8859-1"
fromXmlText {
    characterSet = "ISO-8859-1"
}.toJsonCompliant()

String or binary XML, with a schema and namespace prefixes

XML compliant object

objectConversionFormat = MarshallingFormat.XML
schemaId = "XSD:echo-service:1"
xmlNamespacePrefixMapping = """
    _default = http://www.bccs.uib.no/EchoService.wsdl
    aa = http://www.bccs-aa.uib.no/EchoService.wsdl
""".trimIndent()
fromXmlText {
    schemaId = "XSD:echo-service:1"
    namespacePrefix("_default", "http://www.bccs.uib.no/EchoService.wsdl")
    namespacePrefix("aa", "http://www.bccs-aa.uib.no/EchoService.wsdl")
}.toJsonCompliant()

String or binary XML, with a doctype declaration

XML compliant object

objectConversionFormat = MarshallingFormat.XML
allowInsecureXmlProcessing = true
fromXmlText {
    allowInsecureProcessing = true
}.toJsonCompliant()

Binary

Object

objectConversionFormat = MarshallingFormat.JSON
characterSet = "UTF-16" // default: UTF-8
fromJsonText {
    characterSet = "UTF-16"
}.toJsonCompliant()

Binary

String

characterSet = "UTF-8"
fromBytes().toPlainText()

String

Binary

characterSet = "ISO-8859-1"
fromPlainText().toBytes {
    characterSet = "ISO-8859-1"
}

Object

String

characterSet = "UTF-8"
fromJsonCompliant().toJsonText()

XML compliant object

XML String

objectConversionFormat = MarshallingFormat.XML
characterSet = "UTF-8"
fromJsonCompliant().toXmlText()

XML compliant object

XML String, for sending as ISO-8859-1 bytes

objectConversionFormat = MarshallingFormat.XML
characterSet = "ISO-8859-1"
fromJsonCompliant().toXmlText {
    characterSet = "ISO-8859-1"
}

Object or list

Avro binary (single record)

objectConversionFormat = MarshallingFormat.AVRO_SINGLE_RECORD
schemaId = "AvroSchema:mySchema:latest"
fromJsonCompliant().toAvroSingleRecord {
    schemaId = "AvroSchema:mySchema:latest"
}

List

Avro binary (multiple records)

objectConversionFormat = MarshallingFormat.AVRO_RECORDS
schemaId = "AvroSchema:mySchema:latest"
fromJsonCompliant().toAvroRecords {
    schemaId = "AvroSchema:mySchema:latest"
}

Avro binary (single record)

Object or list

objectConversionFormat = MarshallingFormat.AVRO_SINGLE_RECORD
schemaId = "AvroSchema:mySchema:latest"
fromAvroSingleRecord {
    schemaId = "AvroSchema:mySchema:latest"
}.toJsonCompliant()

Avro binary (multiple records)

List

objectConversionFormat = MarshallingFormat.AVRO_RECORDS
schemaId = "AvroSchema:mySchema:latest"
fromAvroRecords {
    schemaId = "AvroSchema:mySchema:latest"
}.toJsonCompliant()
schemaId identifies a resource in the Resource Registry.
An incoming payload that does not fit the conversion format fails the message.

Conversion by Properties encodes an object’s XML using characterSet, but always encodes its JSON using UTF-8. The processor decodes those bytes using characterSet to obtain a string. If characterSet is not UTF-8, non-ASCII characters in JSON text are corrupted. For XML, characters that characterSet cannot represent are lost.

The XML declaration takes its encoding from the object’s _declaration property, not from characterSet. It can therefore name a different encoding from the one the conversion uses for the XML text. See XML-compliant for _declaration.

With Conversion by Format, toJsonText and toXmlText give the processor a string that keeps every character. toXmlText { characterSet = … } also sets the XML declaration’s encoding to that character set.

MarshallingFormat.AVRO_RECORDS converts like fromAvroRecords and toAvroRecords, and MarshallingFormat.AVRO_SINGLE_RECORD like fromAvroSingleRecord and toAvroSingleRecord. Avro Conversion describes both.

Transformation Properties

To configure how the conversion writes an object as text, set transformerProperties:

inboundTransformationStrategy {
    characterSet = "UTF-8"
    transformerProperties = """
        propertyOne=true
        propertyTwo=true
    """.trimIndent()
}

The following properties are available:

Transformer Property Description Conversion by format

formattedOutput

If true, the conversion indents the JSON string. Defaults to false.

fromJsonCompliant().toJsonText { formattedOutput = true }

ndJsonOutput

If true, the conversion formats the output as newline-delimited JSON. The input must be a JSON-compliant array of objects. Defaults to false.

fromJsonCompliant().toJsonText { ndJsonOutput = true }