Could not initialize class net.liftweb.json.DefaultFormats$

user10360768 Source

I am working in Scala programming language and I am trying to generate json from a case class.

I am following instructions on this page. I have added dependency in pom.xml

<dependency>
    <groupId>net.liftweb</groupId>
    <artifactId>lift-json-scalaz7_2.12</artifactId>
    <version>3.3.0</version>
</dependency>

The code that I have in my worksheet is

import net.liftweb.json._
import net.liftweb.json.Serialization.write

case class Person(name: String, address: Address)
case class Address(city: String, state: String)

val p = Person("Alvin Alexander", Address("Talkeetna", "AK"))
implicit val formats = DefaultFormats
val jsonString = write(p)
println(jsonString)

I get exception: "java.lang.NoClassDefFoundError: Could not initialize class net.liftweb.json.DefaultFormats$"

what could be wrong here?

Thanks

jsonscalacase-classlift-json

Answers

comments powered by Disqus