动态地在数组中添加Json

时间:2016-05-31 07:20:24

标签: json spring rest controller

我使用弹簧工具套件时遇到了Json的问题。

  

@RequestMapping(value =“/ homes {fieldname}”,method = RequestMethod.GET)       @ResponseStatus(value = HttpStatus.OK)       public set lists(@PathVariable(“fieldname”)String fieldname){
          return pspnlRepository.findAllByFieldname(fieldname);       }

这是我的控制器,通过存储库从数据库调用我的数据。

这是Json从这个正常的电话中得到的:

 [
  {
    "fieldname": "field1",
    "inputtype": "text",
    "label": "Field 1",
    "labelgrid": 2,
    "inputgrid": 10,
    "inputlength": 15,
    "isrequired": "Y",
    "ishidden": "N",
    "isenabled": "Y",
    "issearchable": "Y",
    "content": "",
    "recordname": "psdbfield",
    "value": ""
  },
  {
    "fieldname": "field2",
    "inputtype": "email",
    "label": "Field 2",
    "labelgrid": 2,
    "inputgrid": 10,
    "inputlength": 15,
    "isrequired": "Y",
    "ishidden": "N",
    "isenabled": "N",
    "issearchable": "N",
    "content": "",
    "recordname": "psnlfield",
    "value": ""
  }
]

问题是我需要像这样的Json:

[ ---> how can i add this things here (0)
 [ -------> (1)
      {
        "fieldname": "field1",
        "inputtype": "text",
        "label": "Field 1",
        "labelgrid": 2,
        "inputgrid": 10,
        "inputlength": 15,
        "isrequired": "Y",
        "ishidden": "N",
        "isenabled": "Y",
        "issearchable": "Y",
        "content": "",
        "recordname": "psdbfield",
        "value": ""
      },
      {
        "fieldname": "field2",
        "inputtype": "email",
        "label": "Field 2",
        "labelgrid": 2,
        "inputgrid": 10,
        "inputlength": 15,
        "isrequired": "Y",
        "ishidden": "N",
        "isenabled": "N",
        "issearchable": "N",
        "content": "",
        "recordname": "psnlfield",
        "value": ""
      }
    ] ---- > (1)
] --- >> here (0)

我需要它是一个动态数组,因为(1)是定义前端级别。所以它取决于用户(拖放)布局。

0 个答案:

没有答案