cereal icon indicating copy to clipboard operation
cereal copied to clipboard

Deserialize non NVP data into STL containers

Open andrewkcorcoran opened this issue 4 years ago • 0 comments

Currently the cereal deserialisation routines force NVP usage for STL datatypes. This results in mandatory requirement for standardised field names in (for example) XML files. XML files which contain lots of STL containers MUST be composed of fields name key/value/first/value0 etc. or deserialisation will fail. This forces fields with different data to have the same name (e.g. a map of int, std::string and a map of char, double would both have key and value fields, despite the two key's and the two value's representing different data. Having different data represented by the same field name makes generating DTD or XSD validation documents cumbersome and makes validation less robust as it introduces the requirement for mixed field validation rather than exact validation.

It would be great if cereal would support non NVP processing for these fields. Deserialisation of XML (or other archives) that use the de facto key/value etc. fields would still work correctly. However, users using other names for fields (e.g UserId/UserDetails instead of key/value) would also be supported. For serialisation I think the existing behaviour of generating standardised field names is acceptable but perhaps we should look into adding an technique to enable optional renaming of the standardised field names for deserialisation also?

andrewkcorcoran avatar Feb 02 '20 04:02 andrewkcorcoran