简体   繁体   中英

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

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"

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM