Serialize objects in XML and JSON
Serialization MUST be supported using getters , not just object fields.
He MUST support submissions . By concept, I mean a way to specify a subset of the properties of an object that should be serialized. For example, see Getting partial resources at Yahoo! API social platform. I also do not want him to come back infinitely deep:
The presentation must define the properties a) that must be exposed in the entity, and b) the representation for each of them (if they themselves are entities).
For example, an object Personmay have representations fulland simple. When querying views simplefor Person, only properties can be serialized id, firstNameand lastName. When you request a view, the fullproperties motherand father(which themselves Persons) will also be serialized, but only with the view simple(therefore, it will not return to grandparents).
JSON "" , Javascript. , , , -, XML Infoset.
XML null, XML Schema xsi:nil="true".
, , , :
XML JSON
. :
( , ).
, .
. Java, undefined null/empty ( Javascript/JSON, XML, , PHP,...).
XML:
<person>
<lastName>Bon Jovi</lastName>
<friends></friends>
</person>
Person, :
person.setLastName("Bon Jovi");
person.setFriends(new ArrayList());
firstName / father, .
, . id, , .
/ , DTO: a null "unset" " ".