In my spring boot application, I get a request with flat json like this.
{
"firstname" : "a",
"lastname" : "b",
"street": "non main st",
"city": "NY"
}
I want to map to Java object like this.
class Person {
String firstname;
String lastname;
Address address;
}
class Address {
String street;
String city;
}
Is this possible?
Do note that this is for my spring-boot application which automatically deserialize this. I do not use Object Mapper directly.
Controller:
My REST controller is nothing special.
@RestController
public class TestController{
@GetMapping("/")
public void justPrint(@RequestBody Person person){
System.out.println(person);
}
}