users@jersey.java.net

Bug in Null handling in JSON/JAXB ?

From: Jalpesh Patadia <jrp_at_clickbank.com>
Date: Fri, 29 May 2009 14:25:31 -0700

Hello everyone,

My question is similar to what Chad asked in his post, but I'm seeing a slightly different behavior :

https://jersey.dev.java.net/servlets/ReadMsg?listName=users&msgNo=6120


Basically I have some POJO fields which are defined with the @XmlElement element as follows :

@XmlElement(nillable = true) private String status;

Now, when I display the output as application/xml - I get the correct value :

<status xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

However when I use application/json as the output I get :

"status" : {
      "@nil" : "true"
    }

Which seems incorrect. According to the JSON spec, it be more like :

"status" : null


I'm using Jersey 1.0.3. Not sure if this is a bug or working as designed. If it's working as designed, is there a way to make it confirm to the JSON spec ?


Thanks,


Jalpesh




________________________________
PRIVILEGED AND CONFIDENTIAL
This transmission may contain privileged, proprietary or confidential information. If you are not the intended recipient, you are instructed not to review this transmission. If you are not the intended recipient, please notify the sender that you received this message and delete this transmission from your system.