Reputation: 3601
I have different post request bodies like follows:
{
"name": "US",
"amount": "1234"
}
{
"fullName": "US",
"transAmount": "1234"
}
I have created a java filter to modify those request bodies in my spring boot application. I want to convert them in to an uniform format in order to make all the request bodies can be mapped in to same POJO.
Eventually "name" and "fullName" shold be mapped to name, "amount" and "transAmount" should be mapped to amount. How can I achieve this?
Upvotes: 0
Views: 341
Reputation: 15878
Have a look at @JsonAlias here
public class Info {
@JsonAlias({"name", "fullName"}
public String name;
@JsonAlias({"amount", "transAmount"}
public double amount;
}
Upvotes: 1
Reputation: 1269
You can use JsonAlias:
@JsonAlias({"name", "fullName"})
private String name;
Upvotes: 3