I'm using net.sf.json.JSONObject
. A null
value in the JSON object is not equivalent to Java null
. The statement, <c:if test='${not empty obj.value}'>
is not working. Is there any way to compare JSON null
in the JSTL tag?
If you're already on EL 3.0+, then you can do it as follows:
<%@ page import="net.sf.json.JSONObject" %>
...
<c:if test="${JSONObject.NULL eq obj.value}">
If you're not on EL 3.0 yet and thus cannot import constants into EL scope as given above, then use the work around given below which basically checks the Class#getSimpleName()
:
<c:if test="${obj.value['class'].simpleName eq 'JSONNull'}">