summaryrefslogtreecommitdiffstats
path: root/src/corelib/json/qjsonvalue.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/json/qjsonvalue.cpp')
-rw-r--r--src/corelib/json/qjsonvalue.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index 36df146332..b21f59ae35 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -564,6 +564,22 @@ QString QJsonValue::toString(const QString &defaultValue) const
}
/*!
+ Converts the value to a QString and returns it.
+
+ If type() is not String, a null QString will be returned.
+
+ \sa QString::isNull()
+ */
+QString QJsonValue::toString() const
+{
+ if (t != String)
+ return QString();
+ stringData->ref.ref(); // the constructor below doesn't add a ref.
+ QStringDataPtr holder = { stringData };
+ return QString(holder);
+}
+
+/*!
Converts the value to an array and returns it.
If type() is not Array, the \a defaultValue will be returned.