Giter Site home page Giter Site logo

Comments (9)

acruise avatar acruise commented on May 23, 2024

FWIW, lift-json serializes Options as None->Not Present, Some->Present and I haven't seen anyone complaining.

I think you'd be well within your rights to HCF (halt and catch fire ;) when an Option-typed attribute is null. We don't do things that way in Scalaland. The current serialization scheme with empty/value attributes is pretty ugly.

from jackson-module-scala.

cowtowncoder avatar cowtowncoder commented on May 23, 2024

Ok, I appreciate your help. I am not (yet) a Scala user (just play one at jackson projects :) ), so this is helpful to know.

from jackson-module-scala.

advorkovyy avatar advorkovyy commented on May 23, 2024

I think it is fine to serialize null, None and Some(null) as null, Some(x) as x. During deserialization null will become None and x will become Some(x). Yes, serialization and deserialization are not exactly symmetrical in this case, but this is fine since null and Some(null) are rather exceptional cases and are not meant to be useful values for Options.

I do not agree that properties holding None must not be serialized, this is another aspect. None represents missing value, not missing property.

I have coded Option ser/deser using this logic for myself, can share it. I have also support for Scala properties (without @BeanProperty), Scala BigDecimal, BigInt. I plan to add support for Tuples and all Scala collection types using Builders, without JavaConversions. This will preserve unique performance characteristics of each Scala collection type.

from jackson-module-scala.

acruise avatar acruise commented on May 23, 2024

By the way, since I posted my message up there, I discovered (and submitted several patches to) Jerkson, which is a Scala wrapper around Jackson that's pretty good.

from jackson-module-scala.

advorkovyy avatar advorkovyy commented on May 23, 2024

looks more like what I want and need. will give it a try. thanks!

from jackson-module-scala.

cowtowncoder avatar cowtowncoder commented on May 23, 2024

Yeah, I was aware of Jerkson which also looks good. I think there is room for both -- benefit of Jackson scala module is mostly that it has bit more extensive data binding support for POJOs. But Jerkson is more Scala oriented which can be good for many use cases.

Btw I think these would be good discussions for mailing list -- wonder if there should be a separate google group for jackson scala module? For now general jackson mailing list should work ok I guess.

from jackson-module-scala.

christophercurrie avatar christophercurrie commented on May 23, 2024

Started taking a crack at this. On the surface it looks trivial, but the Module system actually doesn't appear to support the use case. In ObjectMapper#_readMapAndClose, if the current token is VALUE_NULL, then the method just returns null; there's no mechanism for the deserializers to kick in and affect the result.

I haven't been able to find an extension point that can affect this. Tatu, can you weigh in?

from jackson-module-scala.

cowtowncoder avatar cowtowncoder commented on May 23, 2024

Right, customization options for handling JSON null values are limited, and especially so as root value (things are bit easier for property values). One thing code probably should do is to actually locate root deserializer, and then call 'deserializer.getNullValue()'. This would help with some other cases (for example, if trying to bind to primitive types; maybe not the smartest thing to do, but with auto-boxing one can pass type Integer.TYPE)...

I will file a Jackson request, and will try to also work on issues you already raised (thanks!).

Btw, I really appreciate help with this module; as with Hibernate, I can't really drive this one too much not being an active Scala developer (yet?)

from jackson-module-scala.

christophercurrie avatar christophercurrie commented on May 23, 2024

Resoved in commit 70cf50e.

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.