내 JSON 파일을 읽으려면 Jackson-jr을 사용하고 있습니다.Jackson-jr 다형성 ArrayList 읽기
[
{"test-1":["a","b","c","d"]},
{"test-2":["b","j","d"]},
{"test-3":["n","e","o","p","i"]},
{"test-4":["s","a","v","z","b","ç","x","p"]},
{"test-5":["d","q","u"]},
{"test-6":["f","b"]}
]
읽어 내 코드는 매우 간단하다 :
InputStream inputStream = assetManager.open("test.json");
ArrayList<HashMap<String, ArrayList<String>>> arrays = JSON.std.beanFrom(ArrayList.class, inputStream);
내 의도는 그들 각각의 작업을 각각의 배열을 얻을 수 있습니다 : 그 중 하나는 약간 복잡
arrays.get(i);
하지만이 줄을 실행하면 예외가 발생합니다.
Caused by: java.lang.ClassCastException: com.fasterxml.jackson.jr.ob.impl.DeferredMap cannot be cast to java.util.HashMap
Jackson-jr에는 TypeFactory, TypeReference 또는 ObjectMapper가 없습니다. 하지 잭슨 주니어를위한 나는 잭슨에 대한 답을 찾을 일부 링크 :
ClassCastException when convert json to list of objects
Jackson custom deserializer for one field with polymorphic types
Tricky(?) JSON, polymorphic deserialization
이는 잭슨 주니어에서이 문제를 처리 할 말 있습니까?
당신은 하루에 저장 – sidgate
을 arrays' '목록 <지도 <문자열, 목록 >>로'arrays' 정의 아래로 할당을 변경합니다. 감사. –
learner