【发布时间】:2019-10-21 11:45:16
【问题描述】:
在使用对象映射器读取值方法读取 json 字符串时发现问题。可以检索各个字段但无法读取数组值,如下所述。
{
"Stuname":"Test",
"State":"CREATE",
"resourceIds": ["{stuId: 814981025958, branches:[10, 4946]}"]
}
使用
objectMapper.readValue(message, StudentState.class);
其中 stuname、state 和 resourceids 集合以及数组也尝试过。但无法阅读。 对于 resourceids 创建了单独的类,其中包含 stuId 和位置数组。
学生状态班:
public class StudentState{
private String Stuname;
private String state;
private Resources [] resourceIds;
//private Collection<Resources> resourceIds;
//Added respective getter/ setter
}
【问题讨论】:
-
能否将
StudentState类的定义添加到问题中? -
你确定你的JSON?
resourceIds是一个没有字符串的数组?
标签: java json objectmapper