0

I am trying to process a huge number of star array responses from one API, it can contain for example 4K of objects, and I am using Jackson ObjectMapper to map the response to the List of my Objects. Here is a simplified example of my class:

 public class MyObject {
    
     private Long price;

 }

Because in odoo you work with just objects is theoretically possible to put in the field which should contain just numbers a String. I would like to handle cases when for example one response will be incorrect but the other will be sent correctly (5,4,1,"not number",..). In this case, I would like to just log the error for the user and process all the other responses. I was wondering if there is some setting for the ObjectMapper or if you don't have others ideas on how to deal with this.

thx for your advice.

  • Please show what you tried so far and how you consume the api – jhueg Jul 25 '22 at 07:38
  • Basically, API is consumed throw XmlRpcClient, which returns just a basic Object containing a list of objects I need to map. There is not a problem, I managed to do it throw the Jackson ObjectMapper, and it will successfully map it in case all objects are correct. But when at least one is incorrect I will get JsonProcessingException. What I need is to get all the other correct repossess. – Tomáš König Jul 25 '22 at 07:56
  • What do you mean by 'a basic Object'? Is it text / a `String`? Is it a Java `Object`? Please provide an example if possible – jhueg Jul 25 '22 at 08:21
  • try this answers: [skip-invalid-records-during-deserialization](https://stackoverflow.com/questions/63836456/how-can-i-tell-jackson-to-skip-invalid-records-during-deserialization) – Marc Stroebel Jul 25 '22 at 08:23

0 Answers0