You can't modify a JValue since it is immutable. Transform function can
be used to make transformation on JValues. Example:
j transform {
case JField("a",JArray(xs)) => JField("a",JArray(JString("x")::xs))
}
Removal is done by transforming a value into JNothing:
j transform {
case JField("a", JArray(xs)) => JNothing
}
Two JSON:s can be merged with 'merge' function:
scala> val j1 = ("foo" -> 1) ~ ("bar" -> 2)
scala> val j2 = ("foo" -> 1) ~ ("baz" -> 3)
scala> j1 merge j2
res6: net.liftweb.json.package.JValue =
JObject(List(JField(foo,JInt(1)), JField(bar,JInt(2)),
JField(baz,JInt(3))))
Those are perhaps the most common ways to make transformations on the
JSON. 'replace' and 'remove' are helpers which can be used too.
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+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
To unsubscribe from this group, send email to liftwe...@googlegroups.com.
--
Henry Minsky