6

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",
  ...
)
hanbzu
  • 880
  • 1
  • 8
  • 14

1 Answers1

7

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.

hanbzu
  • 880
  • 1
  • 8
  • 14