我们正在使用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可以是任何对象