title: How to filter the list based on the value of a key from JsonArray
body: <p>How can I filter a list based on the values of the <code>JSONArray</code>? </p>
  
  <p><code>JSONArray</code> has the elements which is in simple json structure with key and values. </p>
  
  <p><code>JSONArray</code> is from the package <code>org.json</code> and using this dependency</p>
  
  <pre><code>             &lt;dependency&gt;
                 &lt;groupId&gt;org.json&lt;/groupId&gt;
                 &lt;artifactId&gt;json&lt;/artifactId&gt;
                 &lt;version&gt;20180130&lt;/version&gt;
              &lt;/dependency&gt;
  </code></pre>
  
  <p>The string response I get when I hit an endpoint is parsed in this way</p>
  
  <pre><code>   String response = [{"ID": 1,"updatedAt": "2019-04-12T09:09:48"},{"ID": 2,"updatedAt": "2019-04-12T09:09:48"}      
     JSONArray jsonArray =  new JSONArray(response)
  </code></pre>
  
  <p>The list I want to filter consists of list of json strings <code>List&lt;String&gt; eventDataSetList</code></p>
  
  <p>Now how can I filter the list using the value of key <code>ID</code> from <code>jsonArray</code> in a better way than this?</p>
  
  <p>Here is what I have done so far, But I really don't want to use nested loop:</p>
  
  <pre><code>Map&lt;Object, String&gt; filteredEvents = new HashMap&lt;&gt;();
  for (String event : eventDataSetList) {
      for (Object obj : jsonArray) {
          JSONObject jsonObject = (JSONObject) obj;
          if (event.contains(jsonObject.getString("ID"))) {
              filteredEvents.put(jsonObject, event);
          }
      }
  }
  </code></pre>