I use JAXB
and JSONProvider
class for generating response to client in my REST services. And I have found one interesting thing.
I have the mapping:
@XmlRootElement(name = "fooRoot")
@XmlAccessorType(XmlAccessType.FIELD)
public class WSBar {
private WSFooTO foos;
//...
}
@XmlRootElement(name = "foos")
@XmlAccessorType(XmlAccessType.FIELD)
public class WSFooTO {
private WSDateTO one;
private WSDateTO two;
private WSDateTO three;
private WSDateTO four;
//....
}
When I set to the response empty objects, I mean: just new WSDateTO()
and new WSFooTO ()
After the, I recive answer like this:
{"fooRoot":{
"foos":{
"one":"",
"two":"",
"three":"",
"four":""
}
}}
Why does it happen? I expect, that it should be: "one":null, "two":null