mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
refs #815 Throw CJsonException when required JSON objects are not found.
This commit is contained in:
@@ -348,9 +348,13 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
void CPhysicalQuantity<MU, PQ>::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
const QString unitSymbol = json.value("unit").toString();
|
||||
this->setUnitBySymbol(unitSymbol);
|
||||
this->m_value = json.value("value").toDouble();
|
||||
const QJsonValue unit = json.value("unit");
|
||||
const QJsonValue value = json.value("value");
|
||||
if (unit.isUndefined()) { throw CJsonException("Missing 'unit'"); }
|
||||
if (value.isUndefined()) { throw CJsonException("Missing 'value'"); }
|
||||
|
||||
this->setUnitBySymbol(unit.toString());
|
||||
this->m_value = value.toDouble();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
|
||||
Reference in New Issue
Block a user