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 ext
package: 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",
...
)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With