0

I have a controller:

@PostMapping
    public ResponseEntity<BookingDto> saveBooking(@RequestBody BookingDto dto) {
        ...
    }

And my structure is like:

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BookingDto {
    private String id;
    private String guestId;
    private String officeId;
    private OfficeType officeType;
    private String advertId;
    private String guestCount;
    private String[] guestInvites;

    private Map<String, String> testMap;

And I am sending request from postman like :

{
    "guestId" : "0ee9f345-4c2d-45a5-ad30-08fbcf10bb20",
    "officeId" : "917dasd8fc0-643e-11ed-81ce-0242ac120002",
    "officeType" : "1",
    "advertId" : "157fasd43a4-1de6-4fe9-8c7a-ac2164cec6bc",
    "guestCount" : "4",
    "testMap" : ["keyoo : 1", "keyaa : AG"]
}

as you see in pic: enter image description here But It cannot deserialize Map<String,String> object. How can I send and use a Map<String, String> object ?

Jens
  • 67,715
  • 15
  • 98
  • 113
abidinberkay
  • 1,857
  • 4
  • 36
  • 68
  • See https://devqa.io/how-to-convert-java-map-to-json/ https://stackoverflow.com/questions/55072467/sending-map-in-postman-post-request – Oskar Jan 05 '23 at 21:34

1 Answers1

1

Map is a simple JSON object with keys and values

{
    "guestId" : "0ee9f345-4c2d-45a5-ad30-08fbcf10bb20",
    "officeId" : "917dasd8fc0-643e-11ed-81ce-0242ac120002",
    "officeType" : "1",
    "advertId" : "157fasd43a4-1de6-4fe9-8c7a-ac2164cec6bc",
    "guestCount" : "4",
    "testMap" : {"keyoo" : "1", "keyaa" : "AG"}
}