I am moving from C++ to Java, and I am used to the way boost serialization works for xml. What is very good with it is:
-
that I only have to write one function that is used for both parsing and generating the XML. This function is basically a mapping between the field value and the name of the xml tag.
-
that the XML generated is light weight, and only contain the information we want to save (no information about the type of the field, the name of the class…)
I am looking for something that would have the same advantages, in JAVA. Here is a C++ example:
struct ContractDefinition
: public fme::ToStringInterface
{
public:
std::string name;
template<class archive>
void serialize(archive& ar, const unsigned int FME_UNUSED(version))
{
using boost::serialization::make_nvp;
ar & make_nvp< std::string >("name", name);
}
};
and the result looks like that:
<name>WHATEVER THE NAME IS</name>
Take a look at jaxb.