我在文件中有以下JSON
[
{"numberEnrolledPerMonthPerWeek":
{
{"year":"2011","numberEnrolled":0,"weeks":2},
{"year":"2011","numberEnrolled":0,"weeks":3},
{"year":"2011","numberEnrolled":0,"weeks":4},
{"year":"2011","numberEnrolled":0,"weeks":5},
{"year":"2011","numberEnrolled":0,"weeks":6},
{"year":"2011","numberEnrolled":0,"weeks":7},
{"year":"2011","numberEnrolled":0,"weeks":8},
{"year":"2011","numberEnrolled":0,"weeks":9}
}
,"country":"Argentina"
},
]
当我使用Jackson将其反序列化为Java对象时,我收到以下错误
org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token
我正在使用以下代码
ObjectMapper mapper = new ObjectMapper();
List<EnrolledEnrolment> enrolments = mapper.readValue(new File("src/main/resources/data/jsonQueriesTestData1.txt"),
new TypeReference<List<EnrolledEnrolment>>(){});
我已经将typeReference用于初始数组,但是如何在对象EnrolledEnrolment中使用类型Reference作为hashmap。
private Map<Integer, Enrolled> numberEnrolledPerMonthPerWeek = new HashMap<Integer,Enrolled>();
尝试解析第二个数组时会抛出错误?任何想法
由于