开发者

Does the lift-json JValue class have the equivalent of the scala.xml.Node.text method?

When working with scala xml, I find the Node.text method extremely handy. It converts all types开发者_JS百科 of objects into a workable string, which can they cast to the data type you expect (and of course, explode for unexpected data).

Does the lift-json JValue class have a similar method?


I thinks the closest one to that function is 'values'. It returns the pure value wrapped in JValue.

scala> JInt(1).values                                
res0: BigInt = 1

scala> JString("1").values                           
res1: String = 1

scala> JBool(true).values                            
res2: Boolean = true

scala> JArray(List(JInt(1), JInt(2))).values         
res3: List[Any] = List(1, 2)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜