Reputation: 2662
I have a filed, lets say something like this, which is double value boxed to native type or in string.
{ "field1" : 123.00 }
or
{"field1" : "123.00" }
and Corresponding Pojo:
class Response{
Double field1;
}
Now, if its in String format, I see an error as shown below:
Caused by: java.lang.NoSuchFieldError: USE_FAST_DOUBLE_PARSER
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$DoubleDeserializer._parseDouble(NumberDeserializers.java:755)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$DoubleDeserializer.deserialize(NumberDeserializers.java:684)
Apparently the same thing works for Int or long for both string or pure numbers. Why does it fail for Double?
Is there any annotation to use to make it work for both formats? Or fix the issue for parsing from string?
Alternatively, it works using @Jsonsetter.
Thanks
Upvotes: 4
Views: 4458
Reputation: 2662
The Error mentioned was caused by incompatible versions (2.13.x vs 2.14) in Jackson dependencies, as mentioned by @dpr. The fix was to correct versions (keep it same for various dependencies i.e. jackson-core,jackson-databind
, etc.,) and it works for both string and number format which is the default behaviour.
Upvotes: 6