Comments (7)
This uncovers one of the dirtier parts of Scala. The JVM doesn't support using an intrinsic like long
as a type parameter, and Long
is just long
in the Scala type system. At one point I think that they mapped it to the boxed types in the type parameter but that ended up being a source of bugs, so they changed to Object
.
For 2.2, I've added patches to databind to support using @JsonDeserialize
as a workaround:
class OptionLongHolder
{
@JsonDeserialize(contentAs=classOf[java.lang.Long])
var optLong: Option[Long]
}
This works, as it forces Jackson to use Long for deserialization rather than the narrowest natural integer.
from jackson-module-scala.
What is the workaround if your case class is generated for you? I don't have an access to apply attribute.
from jackson-module-scala.
@christophercurrie is it possible to create an optional module that uses what finatra has to work around this? It looks like they use the scala signature parsing https://github.com/twitter/finatra/tree/develop/jackson/src/main/scala/com/twitter/finatra/json/internal/caseclass/jackson
Having to annotate works fine, but its problematic when you are trying to distribute a model class (for example) which now pulls in all of jackson databind. Had the annotation been in jackson-annotations it would be less problematic, but leaking a dependency like that really sucks.
I'd be really open to having a separate module (if we don't want to include that in the main one) that provided for option[long] parsing via signature parsing in the interim, until the deprecation comes around for 2.10>
from jackson-module-scala.
We're currently tied to jackson 2.1.x. Is it somehow possible to get this backported?
from jackson-module-scala.
I'll look into it. AFAIK, core Jackson doesn't plan on any further maintenance on 2.1.x, but I'll see what I can do about an interim release.
from jackson-module-scala.
Ok, thanx!
from jackson-module-scala.
Hello,
Just wanted to thank you for the fix in 2.2. Got a bit stressed when I noticed that conversion bug, so I was relieved to see that it's solved using the @JsonDeserialize(contentAs=classOf[java.lang.Long])
annotation.
from jackson-module-scala.
Related Issues (20)
- investigate major binary compatibility regressions caused by jackson-databind 2.15.0-rc3-SNAPSHOT HOT 4
- Release 2.15.0-rc3 HOT 3
- Release 2.15.0 (final) HOT 2
- Update 2.15 release notes with Scala changes HOT 2
- Release 2.14.3 HOT 2
- Upgrade to Scala 3.3.0
- Release 2.15.1 HOT 1
- support deserializing Scala Iterators HOT 1
- 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
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.