如何在数组中声明新字段
How to declare new fields in array
我的交通工具 class 看起来像这样:
private long fromTimestamp;
private long toTimestamp;
private Integer variableId;
private Integer typeId;
private boolean time;
private String period;
private Object[] columns = {variableId, typeId, time, period};
Class 在我的 Controller 中用作 RequestBody,我不需要字段 variableId、typeId、time 和 period。它应该只在一个数组中。
我这样把参数放在JSON里面是没有意义的:
{
"fromTimestamp": 0,
"toTimestamp": 10,
"variableId": 1,
"typeId": 1,
"time": false,
"period": null,
"columns": [{
"variableId": 1,
"typeId": 1,
"time": false,
"period": null
}]
如何直接在名为列的数组中声明新字段?
你为什么不用这样的东西:
public class Transport {
private long fromTimestamp;
private long toTimestamp;
private Column[] column;
...
}
public class Column {
private Integer variableId;
private Integer typeId;
private boolean time;
private String period;
...
}
我的交通工具 class 看起来像这样:
private long fromTimestamp;
private long toTimestamp;
private Integer variableId;
private Integer typeId;
private boolean time;
private String period;
private Object[] columns = {variableId, typeId, time, period};
Class 在我的 Controller 中用作 RequestBody,我不需要字段 variableId、typeId、time 和 period。它应该只在一个数组中。
我这样把参数放在JSON里面是没有意义的:
{
"fromTimestamp": 0,
"toTimestamp": 10,
"variableId": 1,
"typeId": 1,
"time": false,
"period": null,
"columns": [{
"variableId": 1,
"typeId": 1,
"time": false,
"period": null
}]
如何直接在名为列的数组中声明新字段?
你为什么不用这样的东西:
public class Transport {
private long fromTimestamp;
private long toTimestamp;
private Column[] column;
...
}
public class Column {
private Integer variableId;
private Integer typeId;
private boolean time;
private String period;
...
}