Java has several XML binding frameworks that map Java objects to and from XML. These structures allow you to map different Java hierarchies and classes in the selected XML structure. They can be configured through a separate configuration file. These frameworks include Castor, JiBX and the like. Other structures can be configured programmatically.
Most JSON binding structures simply map the Java object directly to json. Most of them do not extend the flexibility of mapping complex Java hierarchies to any arbitrary selected representation of JSON objects. The configuration is usually quite limited.
I am currently trying to create a web service that returns json responses. If my Java domain classes change in any way, my json responses will also change, causing the service clients waiting for the old version of json responses to break.
Are there any fully flexible JSON binding structures that can map multiple bindings to the same set of classes?
Or (perhaps a more fundamental question), how can I support different versions of JSON bindings in the same set of Java classes?
Or should I just make sure my domain classes never change? (This is not possible)
source share