Comments (9)
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.
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.
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.
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.
looks more like what I want and need. will give it a try. thanks!
from jackson-module-scala.
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.
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.
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.
Resoved in commit 70cf50e.
from jackson-module-scala.
Related Issues (20)
- Release 2.15.2 HOT 2
- Dependency on .class and .tasty files causes footprint bloat for GraalVM NativeImage HOT 5
- Failure to deserialise scala Map when default typing is activated HOT 10
- DefaultScalaModule breaks deserialization of java classes HOT 13
- 2.16 jackson-databind deserialization changes have broken support for the scala.util.Either class HOT 1
- Collection of case classes deserialized as Collection of Map2 HOT 4
- Release 2.15.3 HOT 4
- Release 2.16.0-rc1 HOT 1
- error when deserializing yaml HOT 2
- 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
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.