title: How can I create a JSONPath filter expression containing both AND and OR operators?
body: <p>I have a requirement where i am trying to select objects inside a JSON string by filtering on the presence and/or values of multiple properties of objects inside a JSON array.</p>
  
  <p>Here is an example of my JSON:</p>
  
  <pre><code>{'Fields':[{
    "Sub_Status": "Pending",
    "Status": "Pending",
    "Patient_Gender": "M"
  }]}
  </code></pre>
  
  <p>I want to check this json string using query like this (below query is a SQL query)</p>
  
  <pre><code>string query = TRIM(UPPER(Status)) IN ('PENDING', 'DISPENSED','SHIPMENT') AND TRIM(Patient_Gender) IS NOT NULL
  
  string json_string = {'Fields':[{
    "Sub_Status": "Pending",
    "Status": "Pending",
    "Patient_Gender": "M"
  }]};
  
  var test = json_string.Where(query).toString() /// a return of bool = true or false
  </code></pre>
  
  <p>I tried using JSONPath and also system.linq.dynamic, But no luck.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I need the response in c#. As of now. I tried to use the NewtonSoft.Json SelectToken to select a token using a JSONPath query.</p>
  
  <p>The first part of my query as of now is:</p>
  
  <pre><code>JToken test = s.SelectToken("$.Fields[?(@.Status == 'Pending' || @.Status == 'PENDING' || @.Status == 'SHIPMENT' || @.Status == 'DISPENSED')]");             
  </code></pre>
  
  <p>The second part of my query is:</p>
  
  <pre><code>JToken test = s.SelectToken("$.Fields[?(@.Patient_Gender != '')]");
  </code></pre>
  
  <p>The problem is with "and" operator -- I do not know how to combine them in a single JSONPath query. Individually the queries are working. I need the syntax for the "and" operator. Any suggestions would be helpful.</p>