Wondered if someone could help me out. I have a JSON request
{
"blue": "blue",
"red": "red",
"greens" : {
"lightGreen": "lightGreen",
"darkGreen": "darkGreen"
}
}
which I want to map to a pojo using @RequestBody
done like this:
@PostMapping(path = "/colors", headers = "Accept=application/json")
public void generateClaimDocument(@Valid @RequestBody Colors colors) {
if (colors != null) {
service.doSomethingWithColors(colors);
}
}
Which works fine for blue and red, but it is not mapping JSON greens object at all. Never done this before so could someone shed some light onto how I can do this?
PoJo's:
public class Colors {
private String blue;
private String red;
private Greens greens;
//getters and setters
}
public class Greens {
private String lightGreen;
private String darkGreen;
//getters and setters
}
"red": "red".