我的传输类看起来像这样:
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
}]
如何直接在名为columns的数组中声明新fild?
答案 0 :(得分:0)
为什么不使用这样的东西:
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;
...
}