Giter Site home page Giter Site logo

Comments (7)

christophercurrie avatar christophercurrie commented on May 23, 2024 1

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.

eugeniyk avatar eugeniyk commented on May 23, 2024 1

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.

devshorts avatar devshorts commented on May 23, 2024 1

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

magro avatar magro commented on May 23, 2024

We're currently tied to jackson 2.1.x. Is it somehow possible to get this backported?

from jackson-module-scala.

christophercurrie avatar christophercurrie commented on May 23, 2024

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.

magro avatar magro commented on May 23, 2024

Ok, thanx!

from jackson-module-scala.

PanzerKunst avatar PanzerKunst commented on May 23, 2024

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)

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.