1

我试图在这里做一个例子,并且(我相信)我遇到了问题,因为我的 Lift 版本是错误的。我的具体错误是:java.lang.ClassNotFoundException: com.thoughtworks.paranamer.Paranamer我怎么知道在这种情况下应该使用哪个版本的 Lift?我从这里下载了我的版本

我的代码(直接从上面链接的网站复制):

import net.liftweb.json._
import net.liftweb.json.DefaultFormats

object SarahEmailPluginConfigTest {

implicit val formats = DefaultFormats
case class Mailserver(url: String, username: String, password: String)

val json = parse(
"""
{ 
  "url": "imap.yahoo.com",
  "username": "myusername",
  "password": "mypassword"
}
"""
)

  def main(args: Array[String]) {
    val m = json.extract[Mailserver]
    println(m.url)
    println(m.username)
    println(m.password)
  }

}
4

1 回答 1

-1

Works for me using version lift-json_2.10 3.0-M1

Can be downloaded here.

EDIT

You can use json4s, which usually works exactly the same as lift.

Using these libraries the following works for me:

http://mvnrepository.com/artifact/org.json4s/json4s-native_2.11/3.2.11
http://mvnrepository.com/artifact/org.json4s/json4s-ext_2.11/3.2.11
http://mvnrepository.com/artifact/org.json4s/json4s-core_2.11/3.2.11
http://mvnrepository.com/artifact/org.json4s/json4s-ast_2.11/3.2.11

import org.json4s.DefaultFormats
import org.json4s.native.JsonMethods._

object SarahEmailPluginConfigTest {

  implicit val formats = DefaultFormats
  case class Mailserver(url: String, username: String, password: String)

  val json = parse(
    """
      {
        "url": "imap.yahoo.com",
        "username": "myusername",
        "password": "mypassword"
      }
      """
  )

  def main(args: Array[String]) {
    val m = json.extract[Mailserver]
    println(m.url)
    println(m.username)
    println(m.password)
  }

}
于 2015-08-04T23:16:01.750 回答