Home > database >  How to handle List of multidimensional array as @RequestParam in Spring boot
How to handle List of multidimensional array as @RequestParam in Spring boot

Time:07-12

I need to get value in request body for list of multidimensional array

@RequestBody CreateRequest createRequest


@Getter
@Setter
public class CreateRequest {

    private String id;
    private List<PolygonRequest> boundaries;

    @Getter
    @Setter
    public static class PolygonRequest {
        private String[][] boundary;
    }

}

JSON like,

{
    "id": "Zone 112",
    "boundaries": [
        [
            [-5.2,-6.2],
            [-4.5,-7.8]
        ],
        [
            [7.2,-1.6],
            [-3.3,-8.1]
        ]
    ]
}

When I create like this It is getting Bad request error

"status": 400,
"error": "Bad Request"

CodePudding user response:

Try using the below Array declaration for accessing the String boundary.

private String[][][] boundary;

Also, check for the data type you need(String or Double).

  • Related