Exemplo n.º 1
0
/*!
    \internal
 */
void QJsonObject::setValueAt(int i, const QJsonValue &val)
{
    Q_ASSERT(o && i >= 0 && i < (int)o->length);

    QJsonPrivate::Entry *e = o->entryAt(i);
    insert(e->key(), val);
}
Exemplo n.º 2
0
/*!
    \internal
 */
QString QJsonObject::keyAt(int i) const
{
    Q_ASSERT(o && i >= 0 && i < (int)o->length);

    QJsonPrivate::Entry *e = o->entryAt(i);
    return e->key();
}
Exemplo n.º 3
0
/*!
    Converts this object to a QVariantHash.
    \since 5.5

    Returns the created hash.

    \sa toVariantMap()
 */
QVariantHash QJsonObject::toVariantHash() const
{
    QVariantHash hash;
    if (o) {
        for (uint i = 0; i < o->length; ++i) {
            QJsonPrivate::Entry *e = o->entryAt(i);
            hash.insert(e->key(), QJsonValue(d, o, e->value).toVariant());
        }
    }
    return hash;
}
Exemplo n.º 4
0
/*!
    Converts this object to a QVariantMap.

    Returns the created map.

    \sa toVariantHash()
 */
QVariantMap QJsonObject::toVariantMap() const
{
    QVariantMap map;
    if (o) {
        for (uint i = 0; i < o->length; ++i) {
            QJsonPrivate::Entry *e = o->entryAt(i);
            map.insert(e->key(), QJsonValue(d, o, e->value).toVariant());
        }
    }
    return map;
}
Exemplo n.º 5
0
/*!
    Returns a list of all keys in this object.

    The list is sorted lexographically.
 */
QStringList QJsonObject::keys() const
{
    QStringList keys;
    if (o) {
        keys.reserve(o->length);
        for (uint i = 0; i < o->length; ++i) {
            QJsonPrivate::Entry *e = o->entryAt(i);
            keys.append(e->key());
        }
    }
    return keys;
}
Exemplo n.º 6
0
/*!
    Returns a list of all keys in this object.

    The list is sorted lexographically.
 */
QStringList QJsonObject::keys() const
{
    if (!d)
        return QStringList();

    QStringList keys;

    for (uint i = 0; i < o->length; ++i) {
        QJsonPrivate::Entry *e = o->entryAt(i);
        keys.append(e->key());
    }

    return keys;
}
Exemplo n.º 7
0
/*!
    Returns \c true if \a other is equal to this object.
 */
bool QJsonObject::operator==(const QJsonObject &other) const
{
    if (o == other.o)
        return true;

    if (!o)
        return !other.o->length;
    if (!other.o)
        return !o->length;
    if (o->length != other.o->length)
        return false;

    for (uint i = 0; i < o->length; ++i) {
        QJsonPrivate::Entry *e = o->entryAt(i);
        QJsonValue v(d, o, e->value);
        if (other.value(e->key()) != v)
            return false;
    }

    return true;
}