Spring中的JSON对象数组使用jackson设置作为键值对

时间:2017-12-11 20:24:22

标签: json spring spring-boot jackson

我们正在使用spring boot,我们的响应对象如下:

public class ResponseObj<T> implements Serializable {

    private int status;
    private String message;

     protected List<T> objectList;

// with its respective getter/setters
}

现在,对于客户对象列表,我输出为

{
  "status": 200,
  "message": "Customers fetched successfully",
  "objectList": [
    [
      9,
      "customer1"
    ]
  ]
}

如何通过任何jackson属性或spring boot设置获得具有键/值对的对象输出?

{
      "status": 200,
      "message": "Customers fetched successfully",
      "objectList": [
        {
          "id" : 9,
          "name":"customer1"
        }
      ]
    }

T可以是任何对象

0 个答案:

没有答案