如何使用Jackson将对象转换为以下json格式

时间:2013-10-16 13:13:49

标签: json spring-mvc

我正在尝试使用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]
    ]]
}
}];

0 个答案:

没有答案