Skip to content
Browse files

Add example using fold and append.

  • Loading branch information...
1 parent cf5097e commit 085e00e7f36da9f979379364349bffb0f9eb4eab Joni Freeman committed
Showing with 9 additions and 0 deletions.
  1. +9 −0 lift-json/src/test/scala/net/liftweb/json/Examples.scala
View
9 lift-json/src/test/scala/net/liftweb/json/Examples.scala
@@ -82,6 +82,15 @@ object Examples extends Specification {
compact(render(json)) mustEqual """[{"name":"joe","age":34},{"name":"mazy","age":31}]"""
}
+ "Example which collects all integers and forms a new JSON" in {
+ val json = parse(person)
+ val ints = json.fold(JNothing: JValue) { (a, v) => v match {
+ case x: JInt => a ++ v
+ case _ => a
+ }}
+ compact(render(ints)) mustEqual """[35,33]"""
+ }
+
val lotto = """
{
"lotto":{

0 comments on commit 085e00e

Please sign in to comment.
Something went wrong with that request. Please try again.