on-internet
← Community

JsonUnwrapped to deserialize GET request parameters

Stack Overflow ·

I have the following: @RestController public class MyController { @PostMapping MyDto test(@RequestBody MyDto myDto) { return myDto; } @GetMapping MyDto test2(MyDto myDto) { return myDto; } @Data static class MyDto { private String a; @JsonUnwrapped private MySecondDto secondDto; @Data static class MySecondDto { private String b; } } } However: GET http://localhost:8080?a=a&b=b returns { "a": "a" } while POST http://localhost:8080 { "a": "a", "b": "b" } returns { "a": "a", "b": "b" } so it looks like @JsonUnwrapped and GET mapped Pojos don't work together as expexted. Any hint on how to use com

Comments

Sign in or sign up to comment and upvote.

No comments yet.