title: JSonPath Test for top level value
body: <p>I am using camel with JSonPath - the dependency places the version at 0.9.1</p>
  
  <p>I am attempting to do a content based route based on a jsonpath </p>
  
  <pre><code>        &lt;choice&gt;
              &lt;when&gt;
                  &lt;jsonpath&gt;$.(?(@.headerKey == 'reports'))&lt;/jsonpath&gt;
                  &lt;to uri="direct:echoProcessorReports"/&gt;
              &lt;/when&gt;
              &lt;otherwise&gt;
                  &lt;to uri="direct:echo"/&gt;
              &lt;/otherwise&gt;
          &lt;/choice&gt;
  </code></pre>
  
  <p>The document that will be tested looks like this:</p>
  
  <pre><code>{"headerKey":"reports","data":[{"name":"reports0"},{"name":"reports1"},{"name":"reports2"},{"name":"reports3"},{"name":"reports4"}]}
  </code></pre>
  
  <p>I have been unable to nail down the syntax for this.  I tried various combinations using the jsonpath libraries directly:</p>
  
  <pre><code>import com.jayway.jsonpath.JsonPath;
  import org.apache.camel.jsonpath.JsonPathEngine;
  
  /**
   * Created by mhampton on 1/29/15.
   */
  public class CrapTest {
  
      public static void main(String[] args) {
  
      String data = "{" +
                          "\"headerKey\":\"reports\"," +
                          "\"data\":" +
                              "[{\"name\":\"reports0\"},{\"name\":\"reports1\"},{\"name\":\"reports2\"},{\"name\":\"reports3\"},{\"name\":\"reports4\"}]}";
  
      JsonPath path = JsonPath.compile("$.");
      Object result = path.read(data); //net.minidev.json.JSONObject
      System.out.println(result);
  
      path = JsonPath.compile("$.headerKey");
      result = path.read(data);
      System.out.println(result);
  
      path = JsonPath.compile("$.headerKey(?@ == 'reports)");
      result = path.read(data);
      System.out.println(result);
  
      path = JsonPath.compile("$(?(@.headerKey == 'reports'))");
      result = path.read(data);
      System.out.println(result);
  
      path = JsonPath.compile("$.[*]");
      result = path.read(data);
      System.out.println(result);
      }
  }
  </code></pre>
  
  <p>And I have been able to extract the value ("$.headerKey"), but I cannot seem to get the filter expression to work for it.</p>
  
  <p>Any help greatly appreciated.</p>