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

1

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",
  ...
)
Thinker answered 4/2, 2015 at 19:30 Comment(0)
T
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.

Thinker answered 4/2, 2015 at 19:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.