score:0

It's really best if you can keep the data you're working reasonably consistent. That said, there may be a way to hack around this:

public class Document2 {

    public Document2() { }

    public Document2(double invalid)
    {
        System.out.print("invalid");
    }

    public void setValue1(int value1)
    {
        System.out.println("value1 " + value1);
    }

    public void setValue2(int value2)
    {
        System.out.println("value2 " + value2);
    }
}

In the "happy" case, Jackson will use the default constructor and set the properties as given. In the NaN case, it will find the single-argument double constructor, and leave the other properties alone.


More questions

More questions with similar tag