Skip to content

Instantly share code, notes, and snippets.

@splatch
Created December 6, 2013 12:20
Show Gist options
  • Select an option

  • Save splatch/7822875 to your computer and use it in GitHub Desktop.

Select an option

Save splatch/7822875 to your computer and use it in GitHub Desktop.
public class JacksonDataFormatSplitExpression extends ExpressionAdapter
{
private final JacksonDataFormat format;
private final FormatSchema schema;
public JacksonDataFormatSplitExpression(JacksonDataFormat format, FormatSchema schema)
{
this.format = format;
this.schema = schema;
}
@Override
public Object evaluate(Exchange exchange)
{
try
{
return format.getObjectMapper()
.reader(schema)
.withType(format.getUnmarshalType())
.withView(format.getJsonView())
.readValues(exchange.getIn().getBody(Reader.class));
}
catch (IOException e)
{
throw new RuntimeCamelException("Unable to read data with Jackson object mapper", e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment