From 3035d3caf326e0f01a9b301add6c472f26af4471 Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Mon, 27 Feb 2012 17:12:19 -0800 Subject: [PATCH] Added tests to prove that properties with dashes in the names can be found. http://code.google.com/p/json-path/issues/detail?id=8 --- .../test/java/com/jayway/jsonpath/JsonPathTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java b/json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java index f997eed8..154855a1 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java +++ b/json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java @@ -50,7 +50,8 @@ public class JsonPathTest { " \"color\": \"red\",\n" + " \"price\": 19.95,\n" + " \"foo:bar\": \"fooBar\",\n" + - " \"dot.notation\": \"new\"\n" + + " \"dot.notation\": \"new\",\n" + + " \"dash-notation\": \"dashes\"\n" + " }\n" + " }\n" + "}"; @@ -88,6 +89,13 @@ public class JsonPathTest { assertEquals("new", JsonPath.read(DOCUMENT, "$['store']['bicycle']['dot.notation']")); assertEquals("new", JsonPath.read(DOCUMENT, "$.['store']['bicycle']['dot.notation']")); assertEquals("new", JsonPath.read(DOCUMENT, "$.['store'].['bicycle'].['dot.notation']")); + + System.out.println(ScriptEngineJsonPath.eval(DOCUMENT, "$.store.bicycle.['dash-notation']")); + + assertEquals("dashes", JsonPath.read(DOCUMENT, "$.['store'].bicycle.['dash-notation']")); + assertEquals("dashes", JsonPath.read(DOCUMENT, "$['store']['bicycle']['dash-notation']")); + assertEquals("dashes", JsonPath.read(DOCUMENT, "$.['store']['bicycle']['dash-notation']")); + assertEquals("dashes", JsonPath.read(DOCUMENT, "$.['store'].['bicycle'].['dash-notation']")); } @Test