how to check if a JSONArray is empty in java?

前端 未结 4 884
温柔的废话
温柔的废话 2021-01-01 11:28

I am working on an android app that get json content of a webservice called \"WebUntis\". The Json content i am getting looks like:

{\"jsonrpc\":\"2.0\",\"id         


        
4条回答
  •  迷失自我
    2021-01-01 12:09

    You can also use isEmpty() method, this is the method we use to check whether the list is empty or not. This method returns a Boolean value. It returns true if the list is empty otherwise it gives false. For example:

    if (!k1.isEmpty()) {
        klassenID[i] = kl.getJSONObject(0).getString("id");     
    }
    

提交回复
热议问题