Giter Site home page Giter Site logo

Comments (7)

cowtowncoder avatar cowtowncoder commented on September 23, 2024 1

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.

pjfanning avatar pjfanning commented on September 23, 2024

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.

negokaz avatar negokaz commented on September 23, 2024

@pjfanning
Thank you for your reply.
I understand your situation.
We will try to use case class instead of tuples.

from jackson-module-scala.

pjfanning avatar pjfanning commented on September 23, 2024

I haven't check the deserialization code yet but serialization seems to work (which is a start) - 1741f14

from jackson-module-scala.

pjfanning avatar pjfanning commented on September 23, 2024

@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.

pjfanning avatar pjfanning commented on September 23, 2024

@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.

cowtowncoder avatar cowtowncoder commented on September 23, 2024

@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 nulls 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.