在 <BigDecimal>Java 中使用 Jackson 创建一个 List<List> drom json 值



我得到了这个json:

{"channel":"123","data":"[["7132.09114","0.00800000"],["7131.71462","0.08900000"],["7122.94432","0.75000000"],["7122.87085","0.20000000"],["7122.38788","0.00300000"]]","event":"updated"}

如何从"数据"值中制作列表<列表><大十进制>>?我试图在 readValue(( 中使用 TypeReference 获取它,但我得到了 NPE,因为这个数组在 " 内。

保存数据的类:

public class Result {
@JsonProperty("channel")
private String channel;
@JsonProperty("data")
private List<List<BigDecimal>> data;
}

为什么不使用这样的东西呢?

String jsonInput = "[["7132.09114","0.00800000"],["7131.71462","0.08900000"],["7122.94432","0.75000000"],["7122.87085","0.20000000"],["7122.38788","0.00300000"]]";
List<List<BigDecimal>> myObjects = objectMapper.readValue(jsonInput, new TypeReference<List<List<BigDecimal>>>(){});

相关内容

最新更新