On the serialization of CDM entities in the cdmlib-remote RESTful services

View technologies

The serialization into JSON and XML is in most cases be done by json-lib The according view class which handles serialization to JSON and to XML is @eu.etaxonomy.cdm.remote.view.JsonView@. Whether it serializes to JSON or XML depends on its configuration @JsonView.setType()@. The json and xml views are configured in the following files:

  • cdmlib-remote-webapp/src/main/webapp/WEB-INF/json-views.xml

  • cdmlib-remote-webapp/src/main/webapp/WEB-INF/xml-views.xml

Other services are using different serialization technologies like JAXB/Dozer etc.


Serialization depth

The depth of serialization first of all depends on how deeply an cdm entity and the appendant object graph is initialized.

The actual serialization depth can be configured by two means, the CardinalityPropertyFilter and by class specific JsonBeanProcessor@s. Both are configured in @/cdmlib-remote/src/main/resources/eu/etaxonomy/cdm/remote/json/jsonConfigurations.xml


see eu.etaxonomy.cdm.remote.json.util.CardinalityPropertyFilter


The base class for all bean processors is @eu.etaxonomy.cdm.remote.json.processor.bean.AbstractBeanProcessor@.

Implementation will implement AbstractBeanProcessor.processBeanSecondStep(T bean, JSONObject json, JsonConfig jsonConfig) in order to modify the JSONObject.

It is also possible to specify "excludes" either in the implementation by overriding getIgnorePropNames() (will be default excludes) or in the configuration by setting the excludes via @setExcludes(Set excludes)@. Both methods manage lists of property names to be ignored during the serialization the excludes will be merged with the ones configured by subclasses which override @getIgnorePropNames()@.

Add picture from clipboard (Maximum size: 40 MB)