0

I have a scnario, where one of the property in my POJO is int and In JSON response I will get int type and sometimes I will get String type for the same property.

public class Foo {
   private int id = -1;
   public void setId(int _id){ this.id = _id; }
   public int getId(){ return this.id; }
}

{
  "id": "blah"
}

In This case I don't want to de-serialize.

I want to Ignore de-serialization If I get String type for the Property, Is there anyway to do that?

Note: I don't want to use String and Object type for the property and later handle in the code

Sireesh Vattikuti
  • 1,180
  • 1
  • 9
  • 21
  • Possible duplicate of 1. [Serialization and Deserialization with Jackson: how to programmatically ignore fields?](http://stackoverflow.com/questions/11232045/serialization-and-deserialization-with-jackson-how-to-programmatically-ignore-f) 2.[Ignoring property when deserializing](http://stackoverflow.com/questions/16019834/ignoring-property-when-deserializing) – Abhijeet Feb 22 '16 at 10:47
  • I wan't to ignore the data from JSON if it is of type String, rather completely ignoring the property, JSON is dynamic where the same property has different types of data for different requests – Sireesh Vattikuti Feb 22 '16 at 10:54
  • Pls have a look @ http://stackoverflow.com/a/11243198/452708 answer to [Serialization and Deserialization with Jackson: how to programmatically ignore fields?](http://stackoverflow.com/questions/11232045/serialization-and-deserialization-with-jackson-how-to-programmatically-ignore-f) – Abhijeet Feb 22 '16 at 10:56

0 Answers0