我正在尝试使用通过 GET 到 Spring MVC 控制器的这种特定格式创建一个 json 对象。我为一个相当简单的类工作,该类生成一个扁平的数组 - 但不确定我需要 Polydata 类上的哪些字段来生成以下 Json - 任何提示都表示赞赏。
ResponseEntity<Polydata[]> entity = new ResponseEntity<Polydata[]>(array, headers, HttpStatus.CREATED);
return entity;
我想制作的 Json 格式
var shapes = [{
"type": "Feature",
"properties": {"category": "ABC"},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-104.05, 48.99],
[-97.22, 48.98],
[-96.58, 45.94],
[-104.03, 45.94],
[-104.05, 48.99]
]]
}
}, {
"type": "Feature",
"properties": {"category": "DEF"},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-109.05, 41.00],
[-102.06, 40.99],
[-102.03, 36.99],
[-109.04, 36.99],
[-109.05, 41.00]
]]
}
}];