繁体   English   中英

Json4s 在处理字符串时似乎返回引号,如何强制 Json4s 只返回值?

[英]Json4s seems to return quotes when dealing with strings, how can I force Json4s to just return the value?

如果我使用类似的东西:

{company: {name: "Some Person"}}

然后我使用:

compact(render(json \ "company" \ "name"))

我会回来:

"Some Person"

任何方式回来:

Some Person

不做一些子串?

使用extract

scala> (json \ "company" \ "name").extract[String]
res4: String = Some Person

必要的进口是

import org.json4s._
import org.json4s.jackson.JsonMethods._

并在代码中

implicit val formats = DefaultFormats

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM