Search code examples
scalaenumerationlift-json

Support for Scala Enumeration by net.liftweb.json


I am using the liftweb JSON converter and got it working, by including the dependency in build.sbt like this:

"net.liftweb" %% "lift-json" % "2.6.2"

This all works before I added Enumerations. I can see here that Enumerations are supported, and you should do something like this:

// Scala enums
implicit val formats = net.liftweb.json.DefaultFormats + new EnumSerializer(MyEnum)

But the problem is in my environment the net.liftweb.json.ext package is not recognized. This is the package where EnumSerializer lives.


Solution

  • There is a separate extensions lib that you would need to include. Adding an extra line something like:

    "net.liftweb" %% "lift-json-ext" % "2.6.2"
    

    should do the trick.