The documentation for lift-json suggests that I should be able to call
'values' to get my current JObject structure as a vanilla Scala Map.
This approach is not working for me, as the return type of 'values' is
json.Values rather than a Map as the examples show. What am I doing
wrong?
scala> val json = parse("""{"k1":"v1","k2":"v2"}""")
json: net.liftweb.json.package.JValue = JObject(List(JField(k1,JString(v1)), JField(k2,JString(v2))))
scala> json.values
res4: json.Values = Map((k1,v1), (k2,v2))
scala> res4.get("k1")
<console>:18: error: value get is not a member of json.Values
res4.get("k1")
--
res4.get("k1")
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
'parse' function returns JValue, not JObject. You can cast it to JObject
if you are sure that the JSON you are parsing is a JSON object. The
static type of 'values' function is then known to be a Map.
scala> val json = parse("""{"k1":"v1","k2":"v2"}""")
json: net.liftweb.json.package.JValue =
JObject(List(JField(k1,JString(v1)), JField(k2,JString(v2))))
scala> json.asInstanceOf[JObject].values
res2: scala.collection.immutable.Map[String,Any] = Map((k1,v1), (k2,v2))
Cheers Joni
> --
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb