diff --git a/io/io/src/TBufferJSON.cxx b/io/io/src/TBufferJSON.cxx index f1a3d288ea36717420f2315c73c6f56cca3e16b7..9f1142bf9266ee4463233fb69e03c3c596403949 100644 --- a/io/io/src/TBufferJSON.cxx +++ b/io/io/src/TBufferJSON.cxx @@ -125,6 +125,7 @@ Will produce JSON output: #include "TClonesArray.h" #include "TVirtualMutex.h" #include "TInterpreter.h" +#include "TEmulatedCollectionProxy.h" #include "json.hpp" @@ -666,6 +667,15 @@ TString TBufferJSON::ConvertToJSON(const void *obj, const TClass *cl, Int_t comp return TBufferJSON::ConvertToJSON(ptr, member, compact, arraylen); } + if (cl && cl->GetCollectionProxy() && dynamic_cast<TEmulatedCollectionProxy*>(cl->GetCollectionProxy())) { + ::Error("TBufferJSON::ConvertToJSON", + "The class requested (%s)" + " is an instance of an stl collection and does not have a compiled CollectionProxy." + " Please generate the dictionary for this collection (%s). No data will be written.", + cl->GetName(), cl->GetName()); + return TString(); + } + TBufferJSON buf; buf.SetCompact(compact); @@ -906,6 +916,15 @@ void *TBufferJSON::ConvertFromJSONAny(const char *str, TClass **cl) *cl = nullptr; } + if (objClass && objClass->GetCollectionProxy() && dynamic_cast<TEmulatedCollectionProxy*>(objClass->GetCollectionProxy())) { + ::Error("TBufferJSON::ConvertToJSON", + "The class requested (%s)" + " is an instance of an stl collection and does not have a compiled CollectionProxy." + " Please generate the dictionary for this collection (%s). No data will be written.", + objClass->GetName(), objClass->GetName()); + return nullptr; + } + nlohmann::json docu = nlohmann::json::parse(str); if (docu.is_null() || (!docu.is_object() && !docu.is_array()))