Giter Club home page Giter Club logo

Comments (4)

hekmekk avatar hekmekk commented on July 17, 2024 1

I see. Completely overlooked the imports -.-
Thanks 👍

from enumeratum.

lloydmeta avatar lloydmeta commented on July 17, 2024

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.

hekmekk avatar hekmekk commented on July 17, 2024

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.

lloydmeta avatar lloydmeta commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.