Comments (7)
In particular, trying with 2.14.2 (or 2.15.0-rc2) would be easy step to see that problem still occurs. 2.12 is bit old version.
from jackson-module-scala.
I'm currently travelling and when I get back, I have higher priority items to look at. Using tuples for data binding is supported but not encouraged. Could you use a case class? The JSON will look a little different but case classes are the Scala norm for data binding. You could also try testing with a newer version of this lib. There are also numerous alternative libs out there if this one doesn't suit your needs.
from jackson-module-scala.
@pjfanning
Thank you for your reply.
I understand your situation.
We will try to use case class instead of tuples.
from jackson-module-scala.
I haven't check the deserialization code yet but serialization seems to work (which is a start) - 1741f14
from jackson-module-scala.
@cowtowncoder I tried this deserialization case and the issue is happening in jackson-databind StringDeserializer.
This test case works with scala.Option (this scala class is very similar to java.lang.Optional. But with scala.Option, jackson-module-scala creates a jackson-databind StringDeserializer to handle the deserialization of the underlying value.
jackson-databind StringDeserializer blows up when it sees null
. I'd happily accept back Java null
in this case, because an Option can handle nulls. Is there any way to create a jackson-databind StringDeserializer that accepts nulls?
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1280)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:73)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
from jackson-module-scala.
@cowtowncoder I added this check in the jackson-module-scala code (eb55d7a) so that I can catch the fact the JSON value is null before invoking the inner deserializer.
from jackson-module-scala.
@pjfanning Contract with jackson-databind
is that the "parent" deserializer is to handle null
tokens: so, for example, StringDeserializer
never sees null
but only non-null tokens.
In case of POJO properties, for example, BeanDeserializer
decodes from null
. Same is true for CollectionDeserializer
, array deserializers etc. Original idea was to reduce work for most deserializers (so like StringDeserializer
need not consider this case in any way) but in the end not sure trade-off was correct one. But it is the design.
Given this, TupleDeserializer
needs to handle null
s for fields and NOT delegate to JsonDeserializer
. I can dig up examples if necessary; there's some complexity in providing "null replacement" values.
from jackson-module-scala.
Related Issues (20)
- Release 2.16.0 HOT 2
- release jackson-module-scala v2.12 for Scala 2.10 HOT 2
- Release 2.16.1 HOT 1
- Update `2.17` branch to `2.17.0-rc1-SNAPSHOT` HOT 2
- Release 2.15.4 HOT 1
- Release 2.17.0-rc1 HOT 1
- Release 2.16.2 HOT 2
- Release 2.17.0 HOT 2
- Performance regression with 2.17.x HOT 32
- Update 2.17 release note wiki with Scala module 2.17 fixes HOT 4
- Release 2.17.1 HOT 1
- See if there is benefit from integrating with jackson-databind better wrt detecting "canonical" Constructor for Scala (case) classes HOT 4
- Jackson Scala module build from`master` (v3) fails HOT 16
- investigate OptionSerializerTest default typing test and CaseClassSerializerTest serialize java getters test
- Release 2.17.2 HOT 2
- potentially implement annotation introspector findPrimaryCreator HOT 1
- investigate deserialization case that works in Jackson 2.18 but fails in Jackson 3
- Change to `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` default in 3.0 databind leads to Scala test fails
- Different handling of null and absent value during deserialization HOT 5
- Release 2.18.0-rc1 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jackson-module-scala.