Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT & Json4s serializing Joda Time: How can I access the .ext package?

In my Scala Spray.io application, I would like to turn some Joda LocalTime and LocalDate objects into JSON. This is apparently done by adding JodaTime support from Json4s to the DefaultFormats as follows:

object Json4sProtocol extends Json4sSupport {
  implicit def json4sFormats: Formats = org.json4s.DefaultFormats ++ org.json4s.ext.JodaTimeSerializers.all
}

But for some reason, I'm unable to access the extpackage: object ext is not a member of package org.json4s. Any ideas why this can happen?

I'm well aware that it may be some problem in the way I load the dependencies. I added this line to my build.sbt:

libraryDependencies ++= Seq(
  "org.json4s" %% "json4s-jackson" % "3.2.11",
  ...
)
like image 891
hanbzu Avatar asked Feb 04 '15 19:02

hanbzu


1 Answers

I found out the problem: I was not importing json4-ext.

I added that line in my build.sbt:

libraryDependencies ++= Seq(
  "org.json4s" %% "json4s-jackson" % "3.2.11",
  "org.json4s" %% "json4s-ext" % "3.2.11",
  ...
)

And it worked.

like image 178
hanbzu Avatar answered Oct 24 '22 03:10

hanbzu