title: How to test if JSON Collection object is empty in Java
body: <p>The JSON Collection object I'm receiving looks like this:</p>
  <pre><code>[{&quot;foo1&quot;:&quot;bar1&quot;, &quot;foo2&quot;:&quot;bar2&quot;, &quot;problemkey&quot;: &quot;problemvalue&quot;}]
  </code></pre>
  <p>What I'm trying to test for is the existence of <code>problemvalue</code>. If <code>problemvalue</code> returns a JSON Object, I'm happy.  If it doesn't, it will return as <code>{}</code>.  How do I test for this condition?  I've tried several things to no avail.</p>
  <p>This is what I've tried thus far:</p>
  <pre><code>//      if (obj.get(&quot;dps&quot;) == null) {  //didn't work
  //      if (obj.get(&quot;dps&quot;).equals(&quot;{}&quot;)) {  //didn't work
  if (obj.isNull(&quot;dps&quot;)) {  //didn't work
      System.out.println(&quot;No dps key&quot;);
  }
  </code></pre>
  <p>I expected one of these lines to print &quot;No dps key&quot; because <code>{&quot;dps&quot;:{}}</code>, but for whatever reason, it's not. I'm using <code>org.json</code>. The jar file is <code>org.json-20120521.jar</code>.</p>