https://github.com/pjfanning/jackson-module-scala3-enum
Jackson support for Scala3 enums
https://github.com/pjfanning/jackson-module-scala3-enum
enum jackson scala3
Last synced: 24 days ago
JSON representation
Jackson support for Scala3 enums
- Host: GitHub
- URL: https://github.com/pjfanning/jackson-module-scala3-enum
- Owner: pjfanning
- License: apache-2.0
- Created: 2021-01-02T16:42:30.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-13T20:01:51.000Z (about 1 year ago)
- Last Synced: 2025-04-11T03:52:35.823Z (24 days ago)
- Topics: enum, jackson, scala3
- Language: Scala
- Homepage:
- Size: 87.9 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# jackson-module-scala3-enum

[](https://maven-badges.herokuapp.com/maven-central/com.github.pjfanning/jackson-module-scala3-enum_3)Jackson support for Scala3 [enums](https://dotty.epfl.ch/docs/reference/enums/enums.html).
This was moved into the main jackson-module-scala lib in its 2.17.0 release (https://github.com/FasterXML/jackson-module-scala/issues/501). So there will be no further releases of this separate lib. DefaultScalaModule includes this module.
```
libraryDependencies += "com.github.pjfanning" %% "jackson-module-scala3-enum" % "2.16.0"
``````
import com.github.pjfanning.`enum`.EnumModuleval mapper = JsonMapper.builder()
.addModule(DefaultScalaModule)
.addModule(EnumModule)
.build()//old approach - will not work in Jackson 3
val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)
mapper.registerModule(EnumModule)
```The code uses `toString` on the enum instance to get the serialized value and when deserializing, `valueOf(String)` on the derived companion object is used. It may be possible to use Jackson annotations to modify this behaviour but there have been some issues with how the Scala 3 compiler handles Java annotations (some fixed but some still open).