refs #815 Throw CJsonException when required JSON objects are not found.

This commit is contained in:
Mathew Sutcliffe
2016-12-18 04:44:25 +00:00
parent 7c5c9d30e6
commit bbdbd26f82
10 changed files with 112 additions and 40 deletions

View File

@@ -122,13 +122,17 @@ namespace BlackMisc
void convertFromJson(const QJsonObject &json)
{
derived().clear();
QJsonArray array = json.value("containerbase").toArray();
QJsonValue value = json.value("containerbase");
if (value.isUndefined()) { throw CJsonException("Missing 'containerbase'"); }
QJsonArray array = value.toArray();
int index = 0;
for (auto i = array.begin(); i != array.end(); ++i)
{
CJsonScope scope("containerbase", index++);
QJsonValueRef ref = (*i);
T value;
ref >> value;
derived().insert(value);
T val;
ref >> val;
derived().insert(std::move(val));
}
}