Can Camel be configured to automatically handle data type conversions from JSON to a POJO. For example...looking at Camels website we have the following JSON example: { "id" : 123, "first_name" : "Donald" "last_name" : "Duck" }
and corresponding POJO
public class PersonPojo {
private int id;
private String firstName;
private String lastName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
but does Camel have automatic data type converters where I could set the POJO up to have the ID field unmarshalled to a String object, rather than an int?
Yes, this can be achieved with TypeConverters http://camel.apache.org/type-converter.html
You can also perform this explicitly with the dataFormats element too http://camel.apache.org/data-format.html
Hope that helps :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With