我找到了一个使用以下线程作为参考的解决方案:
Jackson:忽略属性,而不是抛出JsonMappingException
我编写了一个自定义解串器,并用它来忽略错误。
public class CustomListingDeserializer extends JsonDeserializer<Map<String, Listing>>{ public CustomListingDeserializer() { // TODO Auto-generated constructor stub } @Override public Map<String, Listing> deserialize(JsonParser arg0, DeserializationContext arg1) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); JsonNode node = arg0.readValueAsTree(); try { return mapper.readValue(node.toString(), new TypeReference<Map<String,Listing>>(){}); } catch (JsonMappingException e) { System.out.println("Issue in deserializing : " + e.getMessage() + "for :" + node.toString()); } catch (Exception e) { throw e; } // TODO Auto-generated method stub return null; }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)