In one of my REST(-ish) controller methods i receive a json body like the following:
{
id: 123,
otherId: 456,
// ... other properties
}
I want to automatically map this to a class with the following structure
class Foo {
int id;
Bar otherId;
// ...
}
where Bar is
class Bar {
int id;
}
So what i want to do is map otherId to id within otherId.id (Bar.id) and simply change my method signature to.
@RequestMapping(...)
public void doThat(@RequestBody @Valid Foo)
Are there any Annotations that can do this for me or do i have to write a wrapping method myself, etc? Is this possible the way i hope it is?
Regards