Commit b965393c authored by Volker Krause's avatar Volker Krause
Browse files

Support QDate properties in JsonLD::readQDateTime as well

JS can't properly handle date-only values and invents timezones and times
for those, so we need similar workarounds as for preserving timezones on
date/time values there.
parent 32b24604
......@@ -329,7 +329,7 @@ QJSValue JsApi::JsonLd::toJson(const QVariant &v) const
return m_engine->toScriptValue(JsonLdDocument::toJson(v.value<QVector<QVariant>>()));
}
const auto json = JsonLdDocument::toJson(v);
const auto json = JsonLdDocument::toJsonValue(v);
return m_engine->toScriptValue(json);
}
......
......@@ -385,7 +385,7 @@ static QString typeName(const QMetaObject *mo, const QVariant &v)
return QString::fromUtf8(mo->className());
}
static QJsonValue toJsonValue(const QVariant &v)
QJsonValue JsonLdDocument::toJsonValue(const QVariant &v)
{
const auto mo = QMetaType(v.userType()).metaObject();
if (!mo) {
......@@ -482,7 +482,7 @@ QJsonArray JsonLdDocument::toJson(const QVector<QVariant> &data)
{
QJsonArray a;
for (const auto &d : data) {
const auto value = ::toJsonValue(d);
const auto value = toJsonValue(d);
if (!value.isObject()) {
continue;
}
......@@ -495,7 +495,7 @@ QJsonArray JsonLdDocument::toJson(const QVector<QVariant> &data)
QJsonObject JsonLdDocument::toJson(const QVariant& data)
{
const auto value = ::toJsonValue(data);
const auto value = toJsonValue(data);
if (!value.isObject()) {
return {};
}
......
......@@ -53,6 +53,11 @@ public:
/** Serialize instantiated data type to JSON-LD. */
static KITINERARY_EXPORT QJsonObject toJson(const QVariant &data);
/** JSON-LD serrialization of an invidividual data value.
* Unlike the above this also works with primitive types.
*/
static KITINERARY_EXPORT QJsonValue toJsonValue(const QVariant &data);
/** Read property @p name on object @p obj. */
static KITINERARY_EXPORT QVariant readProperty(const QVariant &obj, const char *name);
/** Set property @p name on object @p obj to value @p value. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment