title: Filtering JSon using GSON and lambda
body: <p>I have huge json of the below sample format . I want to filter all items where "d1" equals "St" . I want to delete that object also in case no items are left because of above filtering . </p>
  
  <pre><code>[
  {
    "containertype": "check2",
    "item": [
      {
        "d1": "St"
      },
      {
        "d1": "Pt"
      },
      {
        "d1": "St"
      }
    ],
    "contenttype": "test"
  },
  {
    "containertype": "check2",
    "item": [
      {
        "d1": "St"
      },
      {
        "d1": "St"
      },
      {
        "d1": "st"
      }
    ],
    "contenttype": "test"
  }
  </code></pre>
  
  <p>]</p>
  
  <p>Expected Result </p>
  
  <pre><code>[
  {
    "containertype": "check2",
    "item": [
  
      {
        "d1": "Pt"
      }
    ],
    "contenttype": "test"
  }
  </code></pre>
  
  <p>]</p>
  
  <p>This is what i have tried , i am reading the json , using Gson , i got the map now i am trying to filter the items where the condition is met  . : </p>
  
  <pre><code>    public class Testing {
  public static void main(String[] args) {
  
  
      try {
          final String json = "[{"containertype":"check2","item":[{"d1":"St"},{"d1":"Pt"},{"d1":"St"}],"contenttype":"test"},{"containertype":"check2","item":[{"d1":"Pt"},{"d1":"Pt"},{"d1":"Pt"}],"contenttype":"test"}]";
           Gson gson = new Gson();
          Type rowListType = new TypeToken&lt;List&lt;Map&lt;String, Object&gt;&gt;&gt;() {
          }.getType();
  final List&lt;Map&lt;String, Object&gt;&gt; rows = gson.fromJson(json, rowListType);
              rows.stream()
                      .filter(r -&gt; r.containsKey("item"))
                      .collect(Collectors.toList());
              System.out.println(gson.toJson(rows, rowListType));
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>