【发布时间】:2011-11-09 21:08:59
【问题描述】:
我正在尝试解析属性名称(点)中带有特殊字符的 json 字符串。
这就是我正在尝试的:
//Json parser objects
case class SolrDoc(`rdf.about`:String, `dc.title`:List[String],
`dc.creator`:List[String], `dc.dateCopyrighted`:List[Int],
`dc.publisher`:List[String], `dc.type` :String)
case class SolrResponse(numFound:String, start:String, docs: List[SolrDoc])
val req = url("http://localhost:8983/solr/select") <<? Map("q" -> q)
var search_result = http(req ># { json => (json \ "response") })
var response = search_result.extract[SolrResponse]
即使我的 json 字符串包含所有字段的值,这也是我得到的错误:
Message: net.liftweb.json.MappingException: No usable value for docs
No usable value for rdf$u002Eabout
Did not find value which can be converted into java.lang.String
我怀疑这与名称上的点有关,但到目前为止我还没有设法使它起作用。
谢谢!
这些是我的 LiftProject.scala 文件的摘录:
"net.databinder" % "dispatch-http_2.8.1" % "0.8.6",
"net.databinder" % "dispatch-http-json_2.8.1" % "0.8.6",
"net.databinder" % "dispatch-lift-json_2.8.1" % "0.8.6"
【问题讨论】:
-
Databinder pulls 和旧版本的 lift json,在 lift 邮件列表上有一个关于它的线程,我现在找不到它,但会在今天晚些时候发布链接。