We are building a webservice which consumes and produces JSON.
Problem: We are kind of confused about how to represent some specific details of a object.
Example: we specify any empty element or null element as null in JSON
The question we ask our self is how do we represent a object when its properties are all null.
example: car is a object and color and make are properties, which are null.
We represent it as
car :
{
"color": null,
"make" : null
}
Some people argue that it should be represented as
car : null
So lets say, car : null is the right way to do it. car is not an exact representation of the domain object. its a piece of a domain object, lets call it big car. So we make the car view object in some kind of translator. So we find a painful way of checking each field in the car object and if they are null, then set the car as null, so jackson jaxb provider can render it as null. I know that's not the right way to do it.
Can anyone suggest an alternative??
is there one place where we can check, is there any view object with all children null?? and then set it to null.
which way is more consumable??