Browse Source

add a test for what's described in comment #4 of issue 29

pull/31/head
Jochen Berger 11 years ago
parent
commit
08a2e8e048
  1. 18
      json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java

18
json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java

@ -1,6 +1,9 @@
package com.jayway.jsonpath; package com.jayway.jsonpath;
import com.jayway.jsonpath.internal.IOUtils; import com.jayway.jsonpath.internal.IOUtils;
import net.minidev.json.JSONObject;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.Test; import org.junit.Test;
@ -141,6 +144,21 @@ public class IssuesTest {
Object o = JsonPath.read(json, "$.a"); Object o = JsonPath.read(json, "$.a");
} }
@Test
public void issue_29_a() throws Exception {
String json = "{\"list\": [ { \"a\":\"atext\", \"b.b-a\":\"batext2\", \"b\":{ \"b-a\":\"batext\", \"b-b\":\"bbtext\" } }, { \"a\":\"atext2\", \"b\":{ \"b-a\":\"batext2\", \"b-b\":\"bbtext2\" } } ] }";
List<JSONObject> result = JsonPath.read(json, "$.list[?(@['b.b-a']=='batext2')]");
assertEquals(1, result.size());
assertEquals("atext", result.get(0).get("a"));
result = JsonPath.read(json, "$.list[?(@.b.b-a=='batext2')]");
assertEquals(1, result.size());
assertEquals("atext2", result.get(0).get("a"));
}
@Test @Test
public void issue_29_b() throws Exception { public void issue_29_b() throws Exception {
String json = "{\"list\": [ { \"a\":\"atext\", \"b\":{ \"b-a\":\"batext\", \"b-b\":\"bbtext\" } }, { \"a\":\"atext2\", \"b\":{ \"b-a\":\"batext2\", \"b-b\":\"bbtext2\" } } ] }"; String json = "{\"list\": [ { \"a\":\"atext\", \"b\":{ \"b-a\":\"batext\", \"b-b\":\"bbtext\" } }, { \"a\":\"atext2\", \"b\":{ \"b-a\":\"batext2\", \"b-b\":\"bbtext2\" } } ] }";

Loading…
Cancel
Save