Browse Source

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
pull/3/head
Matt Bishop 13 years ago
parent
commit
3035d3caf3
  1. 10
      json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java

10
json-path/src/test/java/com/jayway/jsonpath/JsonPathTest.java

@ -50,7 +50,8 @@ public class JsonPathTest {
" \"color\": \"red\",\n" + " \"color\": \"red\",\n" +
" \"price\": 19.95,\n" + " \"price\": 19.95,\n" +
" \"foo:bar\": \"fooBar\",\n" + " \"foo:bar\": \"fooBar\",\n" +
" \"dot.notation\": \"new\"\n" + " \"dot.notation\": \"new\",\n" +
" \"dash-notation\": \"dashes\"\n" +
" }\n" + " }\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']")); 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 @Test

Loading…
Cancel
Save