title: How to search an array using JSONPath in Java?
body: <p>I'd like to write a unit test for a web service using json-path-assert. Given this JSON:</p>
  
  <pre><code>[ 
    ["Some short name","Some parent","Some name"],
    ["Some short name 2","Some parent 2","Some name 2"] 
  ]
  </code></pre>
  
  <p>I'd like to check that the parent of "Some name 2" is "Some parent 2". I cannot change the structure of JSON since it is dictated by a third-party library.</p>
  
  <p>Here's the JSONPath expression I came up with:</p>
  
  <pre><code>$..[?(@[2] == 'Some name 2')][1]
  </code></pre>
  
  <p>This expression works fine and gives returns the expected result ('Some parent 2') in <a href="http://www.jsonquerytool.com/" rel="nofollow">this JSON tool</a>. However when using it in Java using the JSONPath library I get an empty result instead of the correct value:</p>
  
  <pre><code>import com.jayway.jsonpath.JsonPath;
  import org.junit.Test;
  
  public class TestJSONPath
  {
    @Test
    public void testJsonPath() {
       String json = "[[\"Some short name\",\"Some parent\",\"Some name\"]," +
         "[\"Some short name 2\",\"Some parent 2\",\"Some name 2\"]]";
  
       System.out.println(JsonPath.read(json, "$[1][1]"));    // OK, returns 'Some parent 2'
       System.out.println(JsonPath.read(json, "$..[?(@[2] == 'Some name 2')][1]")); // Not OK, returns an empty list
   }
  }
  </code></pre>
  
  <p>Here's my pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;test&lt;/groupId&gt;
    &lt;artifactId&gt;test&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.11&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.jayway.jsonpath&lt;/groupId&gt;
        &lt;artifactId&gt;json-path&lt;/artifactId&gt;
        &lt;version&gt;2.1.0&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.jayway.jsonpath&lt;/groupId&gt;
        &lt;artifactId&gt;json-path-assert&lt;/artifactId&gt;
        &lt;version&gt;2.1.0&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Could you please help me with ideas how to overcome this issue?</p>