Comments (8)
what happens if you remove .enable(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY)
?
from jackson-module-scala.
The result is still the same, List[Map]
.
from jackson-module-scala.
I see you are using Int - and type erasure makes that very hard to support.
from jackson-module-scala.
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
@main
def test(): Unit = {
val mapper: JsonMapper = JsonMapper.builder()
.addModule(DefaultScalaModule)
.build()
case class I(i: Option[Int])
case class W(b: List[I])
val d = mapper.readValue[W](
"""
|{ "b": [ { "i": 1 }, { "i": 2 } ] }
|""".stripMargin, classOf[W])
println(d.b.head.i)
}
But when I replaced it with Option[Int]
, it's still the same List[Map]
:
class scala.collection.immutable.Map$Map1 cannot be cast to class test$package$I$1
from jackson-module-scala.
package com.mokahr.tntsync
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
@main
def test(): Unit = {
val mapper: JsonMapper = JsonMapper.builder()
.addModule(DefaultScalaModule)
.build()
case class I(i: Option[Int])
case class W(b: Array[I])
val d = mapper.readValue[W](
"""
|{ "b": [ { "i": 1 }, { "i": 2 } ] }
|""".stripMargin, classOf[W])
println(d.b.head.i)
}
But when I replaced List[I] with Array[I], it was able to print Some(1) normally.
from jackson-module-scala.
There are lots of solutions in that FAQ, could you try some of them? I'm afraid that I don't have time to debug this right now.
There are a lot of other Scala libs to process JSON. This one is constrained by the fact that it uses Java reflection. If you don't like the workarounds in the FAQ, you could try another lib.
from jackson-module-scala.
Okay, I'm just giving feedback on this issue. It doesn't affect my usage at the moment.
from jackson-module-scala.
I added 6441dd9 and the test seems to work ok - maybe I'm missing something
from jackson-module-scala.
Related Issues (20)
- 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
- Update `2.17` branch to `2.17.0-rc1-SNAPSHOT` HOT 2
- Release 2.15.4 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.