Comments (4)
I see. Completely overlooked the imports -.-
Thanks 👍
from enumeratum.
Strange, I just threw the example into Ammonite (Scala 2.12.4) and it seem to work fine.
Can you put up a small repo?
Loading...
Welcome to the Ammonite Repl 1.0.3
(Scala 2.12.4 Java 1.8.0_152)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`com.beachape::enumeratum-json4s:1.5.13`
import $ivy.$
@ import enumeratum.values._
import enumeratum.values._
@ {
sealed abstract class Device(val value: Short) extends ShortEnumEntry
case object Device
extends ShortEnum[Device] /* nothing extra here */ {
case object Phone extends Device(1)
case object Laptop extends Device(2)
case object Desktop extends Device(3)
case object Tablet extends Device(4)
val values = findValues
}
}
defined class Device
defined object Device
@ import org.json4s.DefaultFormats
import org.json4s.DefaultFormats
@
@ implicit val formats = DefaultFormats + Json4s.serializer(Device)
formats: org.json4s.Formats = org.json4s.Formats$$anon$3@3c3357c7
from enumeratum.
Here's an example: https://github.com/hekmekk/enumeratum-json4s-type-mismatch
Thanks for that quick reaction. Hope it's just me missing smth.
from enumeratum.
Ah, ok this is caused by using the wrong Json4s.serializer
. There are 2, one for Enum
and another for ValueEnum
.
I know it can get confusing when you are mixing Enum
with ValueEnum
, but for various reasons, those two things aren't exactly the same thing, even though we try hard to make their APIs align 😅
See hekmekk/enumeratum-json4s-type-mismatch#1 for how you might fix this in your project.
from enumeratum.
Related Issues (20)
- EnumEntry initialization-order problem. HOT 1
- Solution for generic typeclass derivation for Enums! HOT 2
- Any suggested way to forbid calls to `toString` on `EnumEntry`ies? HOT 2
- Cannot initialize enum value with static final Java field HOT 3
- 1.7.1 release is not found in registry HOT 2
- Enums with hierarchical structure HOT 2
- Avoid the use of `toString` for `enumEntry`? HOT 4
- [Scala 2] Compile-time stackoverflow with lots of enum values HOT 3
- Version 1.7.2 is not binary compatible with previous versions HOT 2
- Conflict with Scala 3 enums HOT 5
- Breaking compatibility should trigger a major version update HOT 2
- .
- enumeratum-json4s not available for Scala3? HOT 5
- Scala3: findValues fails to compile in nested sealed trait hierarchy HOT 1
- Scala 3: findValues fails to find entries extending types with type parameters HOT 1
- How to upgrade enumeratum-doobie to target v1.0.0-RC4 HOT 3
- Un-sealed abstract class in hierarchy gets ignored on Scala 3.x HOT 1
- Support play-json 3.0.x
- Members of enums nested in a class are not discovered in scala 3 HOT 1
- Derived `CirceEnum` codecs fail roundtrip on `case class` values HOT 4
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 enumeratum.