15 const nlohmann::json& j) :
21 getAvailableKeys(
const nlohmann::json& j)
24 for (
const auto& item : j.items())
26 ss <<
"\n- " << item.key();
32 NoTypeNameEntryInJsonObject::makeMsg(
const std::string& missingKey,
const nlohmann::json& j)
35 ss <<
"No type name entry with key '" << missingKey <<
"' in JSON object.\n";
38 ss <<
"Available keys: " << getAvailableKeys(j);
42 ss <<
"JSON document is not an object, but a " << j.type_name() <<
".";
48 const std::string& typeName,
49 const nlohmann::json& j) :
55 TypeNameEntryAlreadyInJsonObject::makeMsg(
const std::string& key,
56 const std::string& typeName,
57 const nlohmann::json& j)
60 ss <<
"Key '" << key <<
"' already used in JSON object "
61 <<
"when trying to store the type name '" << typeName <<
"'.\n";
62 ss <<
"Used keys:" << getAvailableKeys(j);
67 const std::string& typeOfObject) :
73 TypeNameMismatch::makeMsg(
const std::string& typeInJson,
const std::string& typeOfObject)
76 ss <<
"Type stored JSON (" << typeInJson <<
") does not match the type of passed object ("
77 << typeOfObject <<
").";
87 const std::string& typeName,
88 const std::vector<std::string>& acceptedTypes) :
94 SerializerAlreadyRegisteredForType::makeMsg(
const std::string& typeName,
95 const std::vector<std::string>& acceptedTypes)
98 ss <<
"There is already a registered serializer for type '" + typeName +
"'.";
99 if (!acceptedTypes.empty())
101 ss <<
"\nAccepted types:\n" + simox::alg::join(acceptedTypes,
"\n- ");
NoTypeNameEntryInJsonObject(const std::string &missingKey, const nlohmann::json &j)
TypeNameEntryAlreadyInJsonObject(const std::string &key, const std::string &typeName, const nlohmann::json &j)