jsonMappingException org.codehaus.jackson.map.JsonMappingException:无法从 START_OBJECT 令牌中反序列化 java.util.ArrayList 的实例
jsonMappingException org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at
我在解析时遇到异常 -
JsonMappingException org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: [B@3f5fb6a4; line: 1, column: 1]
我发现了几个具有相同异常问题的问题,但无法解决我的问题。
您正在尝试将 JSON 对象 解析为 列表。尝试改变
List<Social> topics = objectMapper.readValue(response.data, objectMapper.getTypeFactory().constructCollectionType(List.class, Social.class));
变成类似这样的东西:
Social topics = objectMapper.readValue(response.data, Social.class);
使用这个
JSONObject jsonObject = new JSONObject(response.data);
JSONArray jsonArray = jsonObject.getJSONArray("newUsers");
List<UserObject > userObject = new ObjectMapper().readValue(jsonArray.toString() , new TypeReference<List<UserObject>>(){});
对于 JSONObject 使用 java-json.jar
我在解析时遇到异常 -
JsonMappingException org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token at [Source: [B@3f5fb6a4; line: 1, column: 1]
我发现了几个具有相同异常问题的问题,但无法解决我的问题。
您正在尝试将 JSON 对象 解析为 列表。尝试改变
List<Social> topics = objectMapper.readValue(response.data, objectMapper.getTypeFactory().constructCollectionType(List.class, Social.class));
变成类似这样的东西:
Social topics = objectMapper.readValue(response.data, Social.class);
使用这个
JSONObject jsonObject = new JSONObject(response.data);
JSONArray jsonArray = jsonObject.getJSONArray("newUsers");
List<UserObject > userObject = new ObjectMapper().readValue(jsonArray.toString() , new TypeReference<List<UserObject>>(){});
对于 JSONObject 使用 java-json.jar