*/
/*!
+ \typedef QJsonArray::Iterator
+
+ Qt-style synonym for QJsonArray::iterator.
+*/
+
+/*!
+ \typedef QJsonArray::ConstIterator
+
+ Qt-style synonym for QJsonArray::const_iterator.
+*/
+
+/*!
+ \typedef QJsonArray::size_type
+
+ Typedef for int. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonArray::value_type
+
+ Typedef for QJsonValue. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonArray::difference_type
+
+ Typedef for int. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonArray::pointer
+
+ Typedef for QJsonValue *. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonArray::const_pointer
+
+ Typedef for const QJsonValue *. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonArray::reference
+
+ Typedef for QJsonValue &. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonArray::const_reference
+
+ Typedef for const QJsonValue &. Provided for STL compatibility.
+*/
+
+/*!
Creates an empty array.
*/
QJsonArray::QJsonArray()
The values in \a list will be converted to JSON values.
- \sa toVariantList, QJsonValue::fromString
+ \sa toVariantList(), QJsonValue::fromVariant()
*/
QJsonArray QJsonArray::fromStringList(const QStringList &list)
{
The QVariant values in \a list will be converted to JSON values.
- \sa toVariantList, QJsonValue::fromVariant
+ \sa toVariantList(), QJsonValue::fromVariant()
*/
QJsonArray QJsonArray::fromVariantList(const QVariantList &list)
{
}
/*!
+ \fn QJsonArray::count() const
+
+ Same as size().
+
+ \sa size()
+*/
+
+/*!
Returns \c true if the object is empty. This is the same as size() == 0.
- \sa size
+ \sa size()
*/
bool QJsonArray::isEmpty() const
{
Same as \c at(0).
- \sa at
+ \sa at()
*/
QJsonValue QJsonArray::first() const
{
Same as \c{at(size() - 1)}.
- \sa at
+ \sa at()
*/
QJsonValue QJsonArray::last() const
{
the array can be empty, call isEmpty() before calling this
function.
- \sa removeAt(), takeFirst()
+ \sa removeAt(), removeLast()
*/
/*! \fn void QJsonArray::removeLast()
empty. If the array can be empty, call isEmpty() before calling
this function.
- \sa removeAt(), takeLast()
+ \sa removeAt(), removeFirst()
*/
/*!
}
/*!
+ \fn QJsonArray::iterator QJsonArray::insert(iterator before, const QJsonValue &value)
+
+ Inserts \a value before the position pointed to by \a before, and returns an iterator
+ pointing to the newly inserted item.
+
+ \sa erase(), insert()
+*/
+
+/*!
+ \fn QJsonArray::iterator QJsonArray::erase(iterator it)
+
+ Removes the item pointed to by \a it, and returns an iterator pointing to the
+ next item.
+
+ \sa removeAt()
+*/
+
+/*!
Replaces the item at index position \a i with \a value. \a i must
be a valid index position in the array (i.e., \c{0 <= \a i < size()}).
the assignment will apply to the character in the QJsonArray of QJsonObject
from which you got the reference.
- \sa at(), value()
+ \sa at()
*/
QJsonValueRef QJsonArray::operator [](int i)
{
aware that any non-const function call performed on the QJsonArray
will render all existing iterators undefined.
- \sa QJsonArray::iterator, QJsonArrayIterator
+ \sa QJsonArray::iterator
*/
/*! \fn QJsonArray::const_iterator::const_iterator()
inline const_iterator end() const { return const_iterator(this, size()); }
inline const_iterator constEnd() const { return const_iterator(this, size()); }
iterator insert(iterator before, const QJsonValue &value) { insert(before.i, value); return before; }
- iterator erase(iterator pos) { removeAt(pos.i); return pos; }
+ iterator erase(iterator it) { removeAt(it.i); return it; }
// more Qt
typedef iterator Iterator;
Returns a QJsonDocument representing the data.
- \sa rawData, fromBinaryData, isNull, DataValidation
+ \sa rawData(), fromBinaryData(), isNull(), DataValidation
*/
QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation)
{
/*!
Returns the raw binary representation of the data
- \a size will contain the size of the \a data.
+ \a size will contain the size of the returned data.
This method is useful to e.g. stream the JSON document
in it's binary form to a file.
By default the data is validated. If the \a data is not valid, the method returns
a null document.
- \sa toBinaryData, fromRawData, isNull, DataValidation
+ \sa toBinaryData(), fromRawData(), isNull(), DataValidation
*/
QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidation validation)
{
QVariant::List or QVariant::StringList, the returned document
document is invalid.
- \sa toVariant
+ \sa toVariant()
*/
QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
{
The returned variant will be a QVariantList if the document is
a QJsonArray and a QVariantMap if the document is a QJsonObject.
- \sa fromVariant, QJsonValue::toVariant()
+ \sa fromVariant(), QJsonValue::toVariant()
*/
QVariant QJsonDocument::toVariant() const
{
/*!
Converts the QJsonDocument to a UTF-8 encoded JSON document.
- \sa fromJson
+ \sa fromJson()
*/
QByteArray QJsonDocument::toJson() const
{
/*!
Parses a UTF-8 encoded JSON document and creates a QJsonDocument
- from it. isNull() will return \c false if no error was encountered during
+ from it.
+
+ \a json contains the json document to be parsed.
+
+ The optional \a error variable can be used to pass in a QJsonParseError data
+ structure that will contain information about possible errors encountered during
parsing.
- \sa toJson
+ \sa toJson(), QJsonParseError
*/
QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *error)
{
or computers. fromBinaryData() can be used to convert it back into a
JSON document.
- \sa fromBinaryData
+ \sa fromBinaryData()
*/
QByteArray QJsonDocument::toBinaryData() const
{
Returns an empty object if the document contains an
array.
- \sa isObject, array, setObject
+ \sa isObject(), array(), setObject()
*/
QJsonObject QJsonDocument::object() const
{
Returns an empty array if the document contains an
object.
- \sa isArray, object, setArray
+ \sa isArray(), object(), setArray()
*/
QJsonArray QJsonDocument::array() const
{
/*!
Sets \a object as the main object of this document.
- \sa setArray, object
+ \sa setArray(), object()
*/
void QJsonDocument::setObject(const QJsonObject &object)
{
/*!
Sets \a array as the main object of this document.
- \sa setObject, array
+ \sa setObject(), array()
*/
void QJsonDocument::setArray(const QJsonArray &array)
{
*/
/*!
+ \typedef QJsonObject::Iterator
+
+ Qt-style synonym for QJsonObject::iterator.
+*/
+
+/*!
+ \typedef QJsonObject::ConstIterator
+
+ Qt-style synonym for QJsonObject::const_iterator.
+*/
+
+/*!
+ \typedef QJsonObject::key_type
+
+ Typedef for QString. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonObject::mapped_type
+
+ Typedef for QJsonValue. Provided for STL compatibility.
+*/
+
+/*!
+ \typedef QJsonObject::size_type
+
+ Typedef for int. Provided for STL compatibility.
+*/
+
+
+/*!
Constructs an empty JSON object
\sa isEmpty()
Multiple iterators can be used on the same object. Existing iterators
will however become dangling if the object gets modified.
- \sa QJsonObject::iterator, QJsonObjectIterator
+ \sa QJsonObject::iterator
*/
/*! \typedef QJsonObject::const_iterator::difference_type
*/
/*! \fn bool QJsonObject::const_iterator::operator==(const const_iterator &other) const
+ \fn bool QJsonObject::const_iterator::operator==(const iterator &other) const
Returns \c true if \a other points to the same item as this
iterator; otherwise returns \c false.
*/
/*! \fn bool QJsonObject::const_iterator::operator!=(const const_iterator &other) const
+ \fn bool QJsonObject::const_iterator::operator!=(const iterator &other) const
Returns \c true if \a other points to a different item than this
iterator; otherwise returns \c false.
insert(e->key(), val);
}
-/*! \typedef QJsonObject::Iterator
-
- Qt-style synonym for QJsonObject::iterator.
-*/
-
-/*! \typedef QJsonObject::ConstIterator
-
- Qt-style synonym for QJsonObject::const_iterator.
-*/
-
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QJsonObject &o)
{
*/
/*!
+ \variable QJsonParseError::error
+
+ Contains the type of the parse error. Is equal to QJsonParseError::NoError if the document
+ was parsed correctly.
+
+ \sa ParseError, errorString()
+*/
+
+
+/*!
+ \variable QJsonParseError::offset
+
+ Contains the offset in the input string where the parse error occurred.
+
+ \sa error, errorString()
+*/
+
+/*!
Returns the human-readable message appropriate to the reported JSON parsing error.
+
+ \sa error
*/
QString QJsonParseError::errorString() const
{
}
/*!
+ \fn bool QJsonValue::isNull() const
+
+ Returns true if the value is null.
+*/
+
+/*!
+ \fn bool QJsonValue::isBool() const
+
+ Returns true if the value contains a boolean.
+
+ \sa toBool()
+ */
+
+/*!
+ \fn bool QJsonValue::isDouble() const
+
+ Returns true if the value contains a double.
+
+ \sa toDouble()
+ */
+
+/*!
+ \fn bool QJsonValue::isString() const
+
+ Returns true if the value contains a string.
+
+ \sa toString()
+ */
+
+/*!
+ \fn bool QJsonValue::isArray() const
+
+ Returns true if the value contains an array.
+
+ \sa toArray()
+ */
+
+/*!
+ \fn bool QJsonValue::isObject() const
+
+ Returns true if the value contains an object.
+
+ \sa toObject()
+ */
+
+/*!
+ \fn bool QJsonValue::isUndefined() const
+
+ Returns true if the value is undefined. This can happen in certain
+ error cases as e.g. accessing a non existing key in a QJsonObject.
+ */
+
+
+/*!
Converts \a variant to a QJsonValue and returns it.
The conversion will convert QVariant types as follows:
/*!
Converts the value to a bool and returns it.
- If type() is not bool, the defaultValue will be returned.
+ If type() is not bool, the \a defaultValue will be returned.
*/
bool QJsonValue::toBool(bool defaultValue) const
{
/*!
Converts the value to a double and returns it.
- If type() is not Double, the defaultValue will be returned.
+ If type() is not Double, the \a defaultValue will be returned.
*/
double QJsonValue::toDouble(double defaultValue) const
{
/*!
Converts the value to a QString and returns it.
- If type() is not String, the defaultValue will be returned.
+ If type() is not String, the \a defaultValue will be returned.
*/
QString QJsonValue::toString(const QString &defaultValue) const
{
/*!
Converts the value to an array and returns it.
- If type() is not Array, the defaultValue will be returned.
+ If type() is not Array, the \a defaultValue will be returned.
*/
QJsonArray QJsonValue::toArray(const QJsonArray &defaultValue) const
{
/*!
Converts the value to an object and returns it.
- If type() is not Object, the defaultValue will be returned.
+ If type() is not Object, the \a defaultValue will be returned.
*/
QJsonObject QJsonValue::toObject(const QJsonObject &defaultValue) const
{