From 08a2e8e048dffa4e83769e87eabc8cff96952233 Mon Sep 17 00:00:00 2001 From: Jochen Berger Date: Fri, 23 Aug 2013 09:34:20 +0200 Subject: [PATCH] add a test for what's described in comment #4 of issue 29 --- .../java/com/jayway/jsonpath/IssuesTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java b/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java index 89ade36b..eb805976 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java +++ b/json-path/src/test/java/com/jayway/jsonpath/IssuesTest.java @@ -1,6 +1,9 @@ package com.jayway.jsonpath; import com.jayway.jsonpath.internal.IOUtils; + +import net.minidev.json.JSONObject; + import org.hamcrest.Matchers; import org.junit.Test; @@ -141,6 +144,21 @@ public class IssuesTest { 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 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 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\" } } ] }";