You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-22Lines changed: 26 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -29,16 +29,14 @@ Scala Case Classes, `Sequence`s, `Map`s, `Tuple`s, `Option`s, and Enumerations.
29
29
# Version Support
30
30
31
31
Jackson-module-scala follows the same release strategy of [jackson-databind](https://github.com/FasterXML/jackson-databind).
32
-
Master branch is used for Jackson 3 development. The latest releases are v2.12.x.
32
+
Master branch is used for Jackson 3 development.
33
33
34
-
Scala 2.11, 2.12 and 2.13 are supported. Scala 2.10 support was dropped in v2.12.0. Java 8 is
35
-
the minimum supported version now.
34
+
Scala 2.12, 2.13, 3.3+ are supported. Scala 2.11 support was dropped in v3.0.0. Java 17 is
35
+
the minimum supported version now (Jackson 3 generally has a minimum requirement of Java 17).
36
36
37
37
## Scala 3
38
38
39
-
[Scala 3 support](https://github.com/FasterXML/jackson-module-scala/issues?q=is%3Aissue+is%3Aopen+label%3Ascala3) was added in v2.13.0.
40
39
There are a few differences from Scala 2 support.
41
-
* ScalaObjectMapper is not supported for Scala 3 but ClassTagExtensions is its replacement. (https://github.com/FasterXML/jackson-module-scala/issues/503)
42
40
* There are still a few tests that work with Scala 2 that fail with Scala 3
43
41
* It is expected that most use cases should work ok with Scala 3
44
42
* Known issues with using jackson-module-scala with Scala 3 are tracked at https://github.com/FasterXML/jackson-module-scala/labels/scala3
@@ -50,30 +48,39 @@ To use the Scala Module in Jackson, simply register it with the
50
48
ObjectMapper instance:
51
49
52
50
```scala
53
-
// With 2.10 and later
54
51
valmapper=JsonMapper.builder()
55
52
.addModule(DefaultScalaModule)
56
53
.build()
57
-
58
-
// versions before 2.10 (also support for later 2.x but not 3.0)
59
-
valmapper=newObjectMapper()
60
-
mapper.registerModule(DefaultScalaModule)
61
54
```
62
55
63
56
`DefaultScalaModule` is a Scala object that includes support for all
64
57
currently supported Scala data types. If only partial support is desired,
65
-
the component traits can be included individually:
58
+
the component traits can be included individually (approach differs from Jackson 2):
66
59
67
60
```scala
68
-
valmodule=newOptionModulewithTupleModule {}
61
+
valscalaModule=ScalaModule.builder()
62
+
.addModule(OptionModule)
63
+
.addModule(TupleModule)
64
+
.build()
65
+
69
66
valmapper=JsonMapper.builder()
70
-
.addModule(module)
67
+
.addModule(scalaModule)
71
68
.build()
72
69
```
70
+
If you want to configure the behavior of the ScalaModule but have all the underlying Scala modules, you can do this :
73
71
74
-
Prior to v2.16.0, `ScalaObjectDeserializerModule` was not part of `DefaultScalaModule`. This module is used to
75
-
ensure that deserialization to a Scala object does not create a new instance of the object. Users of older versions can add this
76
-
module explicitly.
72
+
```scala
73
+
valscalaModule=ScalaModule.builder()
74
+
.addAllBuiltinModules()
75
+
.addModule(TupleModule)
76
+
.build()
77
+
78
+
valmapper=JsonMapper.builder()
79
+
.addModule(scalaModule)
80
+
.applyDefaultValuesWhenDeserializing(false) //default of true
DefaultScalaModule is a Scala Object and to access it when you are not compiling with Scala compiler, you will need to use `DefaultScalaModule$.MODULE$` instead.
0 commit comments