Mandar K
Mandar K

Reputation: 405

Generic Json To Object transformer

Is there any way to set the value of "type" attribute of a JsonToObject transformer dynamically ? For ex, A message header will tell you the target Java Object to which incoming Json payload should be converted to. Something like,

<int:json-to-object-transformer 
    input-channel="jsonTransformationChannel" type="headers['targetJavaObject']"
    output-channel="payloadTransformationChannel" />

NOTE : "type" attribute does not support SpEL expressions.

Upvotes: 0

Views: 810

Answers (1)

Gary Russell
Gary Russell

Reputation: 174564

Starting with version 3, the JTOT uses similar headers to the Spring AMQP JSON message converters. See JsonHeaders.

For a simple type, set the json__TypeId__ header to the fully qualified class name and do not configure a type.

Upvotes: 1

Related Questions