How to test if JSON object is empty in Java

前端 未结 15 2402

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

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

What I\'m trying

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

    For this case, I do something like this:

    var obj = {};
    
    if(Object.keys(obj).length == 0){
            console.log("The obj is null")
    }

提交回复
热议问题