How to test if JSON object is empty in Java

前端 未结 15 2403

The JSON object I\'m receiving looks like this:

[{\"foo1\":\"bar1\", \"foo2\":\"bar2\", \"problemkey\": \"problemvalue\"}]

What I\'m trying

15条回答
  •  借酒劲吻你
    2020-12-14 00:27

    A JSON notation {} represents an empty object, meaning an object without members. This is not the same as null. Neither it is string as you are trying to compare it with string "{}". I don't know which json library are you using, but try to look for method something like:

    isEmptyObject() 
    

提交回复
热议问题