Note that there are some explanatory texts on larger screens.

plurals
  1. POIgnoring invalid values in Jackson, using spring
    primarykey
    data
    text
    <p>I use the Spring framework to receive a JSON from a GET request. Everything worked just great, until a wrong value was put in the DB and this happens:</p> <blockquote> <p>02-25 14:46:04.035: E/AndroidRuntime(12271): org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not construct instance of java.util.Date from String value '-3600': not a valid representation (error: Failed to parse Date value '-3600': Can not parse date "-3600": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))</p> </blockquote> <p>How do i set up Jackson to ignore not readable/parseble values? i rather have null or so than that my complete json parsing fails... </p> <p>here is my object i try to parse to, as you can see i tried to ignore properties with jsonignoreproperties in my code.</p> <p>receipt:</p> <pre><code>public class Receipt { public String categories; @JsonProperty("expiration_date") public Date expirationDate; public String image1; public String image2; (.. more properties, getters and setters ..) </code></pre> <p>And how i try to parse :</p> <pre><code>RestTemplate restTemplate = new RestTemplate(); // instellen dat de converter ongedefineerde parameters negeert HttpMessageConverter customconver = new MappingJackson2HttpMessageConverter(); ((MappingJackson2HttpMessageConverter) customconver).getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //here the ignore unknown restTemplate.getMessageConverters().add(customconver); restTemplate.getMessageConverters().add(new StringHttpMessageConverter()); try { // GET Request ResponseEntity&lt;ReceiptMessage&gt; response = restTemplate.exchange(urlPath, HttpMethod.GET,requestEntity,ReceiptMessage.class); </code></pre> <p>keep in mind that BEFORE the -3600 value my parser worked fine, so there is no problem. </p> <p>Is there a way to ignore these kind of errors?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload