From 1678296d5b6190679a9ef950f9421945fa159f8f Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 9 Dec 2018 17:42:06 +0900 Subject: fromJson, fillFromJson: avoid overwriting pods if the JSON value is undefined --- lib/converters.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/converters.h') diff --git a/lib/converters.h b/lib/converters.h index 6227902d..af2be645 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -110,7 +110,8 @@ namespace QMatrixClient template inline void fromJson(const QJsonValue& jv, T& pod) { - pod = fromJson(jv); + if (!jv.isUndefined()) + pod = fromJson(jv); } template @@ -123,13 +124,17 @@ namespace QMatrixClient template inline void fromJson(const QJsonValue& jv, Omittable& pod) { - pod = fromJson(jv); + if (jv.isUndefined()) + pod = none; + else + pod = fromJson(jv); } template inline void fillFromJson(const QJsonValue& jv, T& pod) { - JsonObjectConverter::fillFrom(jv.toObject(), pod); + if (jv.isObject()) + JsonObjectConverter::fillFrom(jv.toObject(), pod); } // JsonConverter<> specialisations -- cgit v1.2.3