Skip to content

Commit da2bd01

Browse files
authored
Update README.md
1 parent e01bc19 commit da2bd01

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@ Scala Case Classes, `Sequence`s, `Map`s, `Tuple`s, `Option`s, and Enumerations.
2929
# Version Support
3030

3131
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.
3333

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).
3636

3737
## Scala 3
3838

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.
4039
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)
4240
* There are still a few tests that work with Scala 2 that fail with Scala 3
4341
* It is expected that most use cases should work ok with Scala 3
4442
* 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
5048
ObjectMapper instance:
5149

5250
```scala
53-
// With 2.10 and later
5451
val mapper = JsonMapper.builder()
5552
.addModule(DefaultScalaModule)
5653
.build()
57-
58-
// versions before 2.10 (also support for later 2.x but not 3.0)
59-
val mapper = new ObjectMapper()
60-
mapper.registerModule(DefaultScalaModule)
6154
```
6255

6356
`DefaultScalaModule` is a Scala object that includes support for all
6457
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):
6659

6760
```scala
68-
val module = new OptionModule with TupleModule {}
61+
val scalaModule = ScalaModule.builder()
62+
.addModule(OptionModule)
63+
.addModule(TupleModule)
64+
.build()
65+
6966
val mapper = JsonMapper.builder()
70-
.addModule(module)
67+
.addModule(scalaModule)
7168
.build()
7269
```
70+
If you want to configure the behavior of the ScalaModule but have all the underlying Scala modules, you can do this :
7371

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+
val scalaModule = ScalaModule.builder()
74+
.addAllBuiltinModules()
75+
.addModule(TupleModule)
76+
.build()
77+
78+
val mapper = JsonMapper.builder()
79+
.addModule(scalaModule)
80+
.applyDefaultValuesWhenDeserializing(false) //default of true
81+
.supportScala3Classes(false) //default of true
82+
.build()
83+
```
7784

7885
## DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES
7986

@@ -94,9 +101,6 @@ You can also mixin `ClassTagExtensions` to get rich wrappers that automatically
94101
convert scala ClassTags directly into TypeReferences for Jackson to use:
95102
```scala
96103
val mapper = JsonMapper.builder().addModule(DefaultScalaModule).build() :: ClassTagExtensions
97-
// or using old style
98-
//val mapper = new ObjectMapper() with ClassTagExtensions
99-
//mapper.registerModule(DefaultScalaModule)
100104
val myMap = mapper.readValue[Map[String, Tuple2[Int,Int]]](src)
101105
```
102106

@@ -114,17 +118,18 @@ Consult the [Scaladoc](https://fasterxml.github.io/jackson-module-scala/latest/a
114118

115119
To import in sbt:
116120
```scala
117-
libraryDependencies += "tools.jackson.module" %% "jackson-module-scala" % "3.0.0-SNAPSHOT"
121+
libraryDependencies += "tools.jackson.module" %% "jackson-module-scala" % "3.0.0-rc1-SNAPSHOT"
118122
```
119123

120124
## Java/Kotlin users
121125

122126
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.
123127

124128
```java
125-
import tools.jackson.module.scala.DefaultScalaModule$;
129+
import tools.jackson.module.scala.*;
126130

127131
ObjectMapper mapper = JsonMapper.builder().addModule(DefaultScalaModule$.MODULE$).build();
132+
// or ScalaModule.builder().addAllBuiltinModules().build() instead of DefaultScalaModule$.MODULE$
128133
```
129134

130135
# Building
@@ -147,7 +152,6 @@ well suited to end users, as most classes are implementation details of the modu
147152
* [jackson-scala-reflect-extensions](https://github.com/pjfanning/jackson-scala-reflect-extensions)
148153
* [jackson-scala3-reflect-extensions](https://github.com/pjfanning/jackson-scala3-reflection-extensions)
149154
* [jackson-module-enumeratum](https://github.com/pjfanning/jackson-module-enumeratum)
150-
* [jackson-module-scala3-enum](https://github.com/pjfanning/jackson-module-scala3-enum) -- since v2.17.0, this is included in jackson-module-scala
151155
* [jackson-caffeine-cache](https://github.com/pjfanning/jackson-caffeine-cache)
152156

153157
# Contributing

0 commit comments

Comments
 (0)