summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsonvalue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/serialization/qjsonvalue.cpp')
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp
index 9fecbbb6266..37ead9648eb 100644
--- a/src/corelib/serialization/qjsonvalue.cpp
+++ b/src/corelib/serialization/qjsonvalue.cpp
@@ -921,6 +921,7 @@ bool QJsonValue::operator!=(const QJsonValue &other) const
void QJsonValueRef::detach()
{
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
QCborContainerPrivate *d = QJsonPrivate::Value::container(*this);
d = QCborContainerPrivate::detach(d, d->elements.size());
@@ -928,6 +929,9 @@ void QJsonValueRef::detach()
o->o.reset(d);
else
a->a.reset(d);
+#else
+ d = QCborContainerPrivate::detach(d, d->elements.size());
+#endif
}
static QJsonValueRef &assignToRef(QJsonValueRef &ref, const QCborValue &value, bool is_object)
@@ -1036,6 +1040,18 @@ QJsonValue QJsonValueConstRef::concrete(QJsonValueConstRef self) noexcept
return QJsonPrivate::Value::fromTrustedCbor(d->valueAt(index));
}
+QString QJsonValueConstRef::objectKey(QJsonValueConstRef self)
+{
+ Q_ASSERT(self.is_object);
+ Q_ASSUME(self.is_object);
+ const QCborContainerPrivate *d = QJsonPrivate::Value::container(self);
+ qsizetype index = QJsonPrivate::Value::indexHelper(self);
+
+ Q_ASSERT(d);
+ Q_ASSERT(index < d->elements.size());
+ return d->stringAt(index - 1);
+}
+
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
QVariant QJsonValueRef::toVariant() const
{