diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/converters.h | 11 |
1 files changed, 8 insertions, 3 deletions
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 <typename T> inline void fromJson(const QJsonValue& jv, T& pod) { - pod = fromJson<T>(jv); + if (!jv.isUndefined()) + pod = fromJson<T>(jv); } template <typename T> @@ -123,13 +124,17 @@ namespace QMatrixClient template <typename T> inline void fromJson(const QJsonValue& jv, Omittable<T>& pod) { - pod = fromJson<T>(jv); + if (jv.isUndefined()) + pod = none; + else + pod = fromJson<T>(jv); } template <typename T> inline void fillFromJson(const QJsonValue& jv, T& pod) { - JsonObjectConverter<T>::fillFrom(jv.toObject(), pod); + if (jv.isObject()) + JsonObjectConverter<T>::fillFrom(jv.toObject(), pod); } // JsonConverter<> specialisations |