cereal icon indicating copy to clipboard operation
cereal copied to clipboard

Json/XML Archive improvement

Open ChrisBFX opened this issue 9 years ago • 3 comments

Better error messages when loading of nvp fails. You can now see the complete path of nvps that fails which helps if you're parsing big xml/json archives with nested data structures.

The name of the root node in the xml can now be configured on a per archive basis (default is the one set with the CEREAL_XML_STRING_VALUE macro, so no everything should work as before) which is easier than the macro (which is not always possible if you want to use different root names and polymorphism support).

ChrisBFX avatar Jul 28 '16 13:07 ChrisBFX

Can you clarify the NVP exception changes you've made here? We already throw an exception (cereal::Exception) if we can't find the NVP - are you trying to catch other potential errors (I see you catch std::exception).

AzothAmmo avatar Jul 29 '16 22:07 AzothAmmo

Yes this catches more errors, f.e. when rapidjson can't parse a value cause of a type-mismatch it throws an exception, so this would give you more info. (Though I'm seeing now you modified rapidjson to throw an cereal::Exception, so i guess it would be ok to change the catch in the json archive to cereal::Exception, the xml archive though uses the std::stoll (and similar) functions to parse the values which throw std::exception so i wouldn't change the catch there). Another reason is that it's sometimes difficult to find out which NVP exactly is missing if you have nested data structures like:

{
  "id": 1,
  "config": {
     "id": 2,
     "data": {
         "identifier": 3
      }
   }
}

ChrisBFX avatar Aug 01 '16 09:08 ChrisBFX

any news here? a configurable root node would be helpful.

wheeler1818 avatar Oct 26 '21 13:10 wheeler1818