diff options
author | Johannes Rudolph <johannes_rudolph@gmx.de> | 2012-05-29 11:22:10 +0200 |
---|---|---|
committer | Johannes Rudolph <johannes_rudolph@gmx.de> | 2012-05-29 11:22:10 +0200 |
commit | 28ddef4d5bbd801b82ebe78a100fcbb25e1d8a67 (patch) | |
tree | dfd1a200d4a3ed73ee27de995ba3c70500a4c49c /src/test/scala/cc | |
parent | 11ea417a0057105a6f7129babb899cb132aebb73 (diff) | |
download | spray-json-28ddef4d5bbd801b82ebe78a100fcbb25e1d8a67.tar.gz spray-json-28ddef4d5bbd801b82ebe78a100fcbb25e1d8a67.tar.bz2 spray-json-28ddef4d5bbd801b82ebe78a100fcbb25e1d8a67.zip |
implemented array element extraction
Diffstat (limited to 'src/test/scala/cc')
-rw-r--r-- | src/test/scala/cc/spray/json/JsonLensesSpec.scala | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/test/scala/cc/spray/json/JsonLensesSpec.scala b/src/test/scala/cc/spray/json/JsonLensesSpec.scala index 345caff..2167fae 100644 --- a/src/test/scala/cc/spray/json/JsonLensesSpec.scala +++ b/src/test/scala/cc/spray/json/JsonLensesSpec.scala @@ -28,13 +28,18 @@ class JsonLensesSpec extends Specification { "Lenses" should { "access" in { "field" in { - n.get[Int].apply(json) must be_==(2) + "n".get[Int].apply(json) must be_==(2) } "field of member" in { - val json = JsonParser( """{"n": {"b": 4}}""") + val json = JsonParser("""{"n": {"b": 4}}""") ("n" / "b").get[Int].apply(json) must be_==(4) } + "element of array" in { + val json = JsonParser("""["a", "b", 2, 5, 8, 3]""") + + json extract element(3).get[Int] must be_==(5) + } } "modify" in { @@ -57,6 +62,11 @@ class JsonLensesSpec extends Specification { json update ("n" / "b" ! updated[Int](1 +)) must be_json( """{"n": {"b": 5}}""") } + "set element of array" in { + val json = JsonParser("""["a", "b", 2, 5, 8, 3]""") + + json update (element(3) ! set(35)) must be_json("""["a", "b", 2, 35, 8, 3]""") + } } } |