How to check if JSONArray Element is null

前端 未结 3 478
渐次进展
渐次进展 2020-12-11 02:25

I can\'t figure out how to determine is an element that lives inside a json array is null. To check if the jsonObject itself is null, you simply use:

jsonObj         


        
3条回答
  •  忘掉有多难
    2020-12-11 03:10

    I guess json passes null values as strings, so you can't check null as a java element. Instead treat the null value as a string as check this way:

    if(!mapItem.getString("date").equals("null")) {
        //Value is not null
    }
    

    I have updated the code snippet in the original question to a working version.

提交回复
热议问题