QJsonArray Class
La clase QJsonArray encapsula un array JSON. Más...
| Cabecera: | #include <QJsonArray> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core)target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
- Lista de todos los miembros, incluyendo los heredados
- QJsonArray es parte de Soporte JSON en Qt y Clases Implícitamente Compartidas.
Esta clase es comparable en igualdad de condiciones.
Esta clase es comparable con QJsonValue.
Nota: Todas las funciones de esta clase son reentrantes.
Tipos Públicos
| class | const_iterator |
| class | iterator |
| ConstIterator | |
| Iterator | |
| const_pointer | |
| const_reference | |
| difference_type | |
| pointer | |
| reference | |
| size_type | |
| value_type |
Funciones Públicas
| QJsonArray() | |
| QJsonArray(std::initializer_list<QJsonValue> args) | |
| QJsonArray(const QJsonArray &other) | |
| QJsonArray(QJsonArray &&other) | |
| ~QJsonArray() | |
| void | append(const QJsonValue &value) |
| QJsonValue | at(qsizetype i) const |
| QJsonArray::iterator | begin() |
| QJsonArray::const_iterator | begin() const |
| QJsonArray::const_iterator | cbegin() const |
| QJsonArray::const_iterator | cend() const |
| QJsonArray::const_iterator | constBegin() const |
| QJsonArray::const_iterator | constEnd() const |
| bool | contains(const QJsonValue &value) const |
| qsizetype | count() const |
| bool | empty() const |
| QJsonArray::iterator | end() |
| QJsonArray::const_iterator | end() const |
| QJsonArray::iterator | erase(QJsonArray::iterator it) |
| QJsonValue | first() const |
| QJsonArray::iterator | insert(QJsonArray::iterator before, const QJsonValue &value) |
| void | insert(qsizetype i, const QJsonValue &value) |
| bool | isEmpty() const |
| QJsonValue | last() const |
| void | pop_back() |
| void | pop_front() |
| void | prepend(const QJsonValue &value) |
| void | push_back(const QJsonValue &value) |
| void | push_front(const QJsonValue &value) |
| void | removeAt(qsizetype i) |
| void | removeFirst() |
| void | removeLast() |
| void | replace(qsizetype i, const QJsonValue &value) |
| qsizetype | size() const |
| void | swap(QJsonArray &other) |
| QJsonValue | takeAt(qsizetype i) |
| QVariantList | toVariantList() const |
| QJsonArray | operator+(const QJsonValue &value) const |
| QJsonArray & | operator+=(const QJsonValue &value) |
| QJsonArray & | operator<<(const QJsonValue &value) |
| QJsonArray & | operator=(QJsonArray &&other) |
| QJsonArray & | operator=(const QJsonArray &other) |
| QJsonValueRef | operator[](qsizetype i) |
| QJsonValue | operator[](qsizetype i) const |
Miembros públicos estáticos
| QJsonArray | fromStringList(const QStringList &list) |
| QJsonArray | fromVariantList(const QVariantList &list) |
No miembros relacionados
| bool | operator!=(const QJsonArray &lhs, const QJsonArray &rhs) |
| bool | operator==(const QJsonArray &lhs, const QJsonArray &rhs) |
Descripción Detallada
Un array JSON es una lista de valores. La lista puede manipularse insertando y eliminando QJsonValue's de la matriz.
Un QJsonArray puede ser convertido a y desde un QVariantList. Puedes consultar el número de entradas con size(), insert(), y removeAt() entradas desde él e iterar sobre su contenido usando el patrón iterador estándar de C++.
QJsonArray es una clase implícitamente compartida y comparte los datos con el documento a partir del cual se ha creado mientras no se modifique.
Puedes convertir el array a y desde JSON basado en texto a través de QJsonDocument.
Ver también Soporte JSON en Qt y Guardar y Cargar un Juego.
Documentación de Tipos de Miembros
QJsonArray::ConstIterator
Qt-style sinónimo de QJsonArray::const_iterator.
QJsonArray::Iterator
Qt-style sinónimo de QJsonArray::iterator.
QJsonArray::const_pointer
Typedef para const QJsonValue *. Proporcionado para la compatibilidad STL.
QJsonArray::const_reference
Typedef para const QJsonValue &. Se proporciona por compatibilidad con STL.
QJsonArray::difference_type
Typedef para qsizetype. Se proporciona por compatibilidad con STL.
QJsonArray::pointer
Typedef para QJsonValue *. Proporcionado para la compatibilidad STL.
QJsonArray::reference
Typedef para QJsonValue &. Proporcionado para compatibilidad STL.
QJsonArray::size_type
Typedef para qsizetype. Se proporciona por compatibilidad con STL.
QJsonArray::value_type
Typedef para QJsonValue. Se proporciona por compatibilidad con STL.
Documentación de funciones miembro
QJsonArray::QJsonArray()
Crea un array vacío.
QJsonArray::QJsonArray(std::initializer_list<QJsonValue> args)
Crea un array inicializado a partir de la lista de inicialización args.
QJsonArray puede construirse de forma similar a la notación JSON, por ejemplo:
QJsonArray array = { 1, 2.2, QString() };
[noexcept] QJsonArray::QJsonArray(const QJsonArray &other)
Crea una copia de other.
Dado que QJsonArray se comparte implícitamente, la copia es superficial mientras el objeto no se modifique.
[noexcept] QJsonArray::QJsonArray(QJsonArray &&other)
Move-construye un QJsonArray a partir de other.
[noexcept] QJsonArray::~QJsonArray()
Borra el array.
void QJsonArray::append(const QJsonValue &value)
Inserta value al final del array.
Véase también prepend() y insert().
QJsonValue QJsonArray::at(qsizetype i) const
Devuelve un QJsonValue que representa el valor del índice i.
El QJsonValue devuelto es Undefined, si i está fuera de los límites.
QJsonArray::iterator QJsonArray::begin()
Devuelve un iterador de estilo STL que apunta al primer elemento de la matriz.
Véase también constBegin() y end().
QJsonArray::const_iterator QJsonArray::begin() const
Se trata de una función sobrecargada.
QJsonArray::const_iterator QJsonArray::cbegin() const
Devuelve un iterador const de estilo STL que apunta al primer elemento de la matriz.
Véase también begin() y cend().
QJsonArray::const_iterator QJsonArray::cend() const
Devuelve un iterador const de estilo STL que apunta al elemento imaginario después del último elemento de la matriz.
Véase también cbegin() y end().
QJsonArray::const_iterator QJsonArray::constBegin() const
Devuelve un iterador const de estilo STL que apunta al primer elemento de la matriz.
Véase también begin() y constEnd().
QJsonArray::const_iterator QJsonArray::constEnd() const
Devuelve un iterador const de estilo STL que apunta al elemento imaginario después del último elemento de la matriz.
Véase también constBegin() y end().
bool QJsonArray::contains(const QJsonValue &value) const
Devuelve true si el array contiene una ocurrencia de value, en caso contrario false.
Véase también count().
qsizetype QJsonArray::count() const
Igual que size().
Véase también size().
bool QJsonArray::empty() const
Esta función se proporciona por compatibilidad con STL. Es equivalente a isEmpty() y devuelve true si la matriz está vacía.
QJsonArray::iterator QJsonArray::end()
Devuelve un iterador de estilo STL que apunta al elemento imaginario después del último elemento de la matriz.
Véase también begin() y constEnd().
QJsonArray::const_iterator QJsonArray::end() const
Se trata de una función sobrecargada.
QJsonArray::iterator QJsonArray::erase(QJsonArray::iterator it)
Elimina el elemento apuntado por it, y devuelve un iterador apuntando al siguiente elemento.
Véase también removeAt().
QJsonValue QJsonArray::first() const
Devuelve el primer valor almacenado en el array.
Igual que at(0).
Véase también at().
[static] QJsonArray QJsonArray::fromStringList(const QStringList &list)
Convierte la lista de cadenas list en una QJsonArray.
Los valores de list se convertirán en valores JSON.
Véase también toVariantList() y QJsonValue::fromVariant().
[static] QJsonArray QJsonArray::fromVariantList(const QVariantList &list)
Convierte la lista de variantes list en una QJsonArray.
Los valores de QVariant en list se convertirán en valores JSON.
Nota: La conversión desde QVariant no es completamente sin pérdidas. Consulte la documentación de QJsonValue::fromVariant() para obtener más información.
Véase también toVariantList() y QJsonValue::fromVariant().
QJsonArray::iterator QJsonArray::insert(QJsonArray::iterator before, const QJsonValue &value)
Inserta value antes de la posición apuntada por before, y devuelve un iterador apuntando al elemento recién insertado.
Véase también erase() y insert(qsizetype, const QJsonValue &).
void QJsonArray::insert(qsizetype i, const QJsonValue &value)
Inserta value en la posición de índice i de la matriz. Si i es 0, el valor se añade a la matriz. Si i es size(), el valor se añade a la matriz.
Véase también append(), prepend(), replace() y removeAt().
bool QJsonArray::isEmpty() const
Devuelve true si el objeto está vacío. Es lo mismo que size() == 0.
Véase también size().
QJsonValue QJsonArray::last() const
Devuelve el último valor almacenado en el array.
Igual que at(size() - 1).
Véase también at().
void QJsonArray::pop_back()
Esta función se proporciona por compatibilidad con STL. Es equivalente a removeLast(). La matriz no debe estar vacía. Si la matriz puede estar vacía, llame a isEmpty() antes de llamar a esta función.
void QJsonArray::pop_front()
Esta función se proporciona por compatibilidad con STL. Es equivalente a removeFirst(). La matriz no debe estar vacía. Si la matriz puede estar vacía, llame a isEmpty() antes de llamar a esta función.
void QJsonArray::prepend(const QJsonValue &value)
Inserta value al principio de la matriz.
Es lo mismo que insert(0, value) y añade value a la matriz.
Véase también append() y insert().
void QJsonArray::push_back(const QJsonValue &value)
Esta función se proporciona por compatibilidad con STL. Es equivalente a append(valor) y añadirá value a la matriz.
void QJsonArray::push_front(const QJsonValue &value)
Esta función se proporciona por compatibilidad con STL. Es equivalente a prepend(valor) y añadirá value a la matriz.
void QJsonArray::removeAt(qsizetype i)
Elimina el valor en la posición de índice i. i debe ser una posición de índice válida en la matriz (es decir, 0 <= i < size()).
Véase también insert() y replace().
void QJsonArray::removeFirst()
Elimina el primer elemento de la matriz. Llamar a esta función es equivalente a llamar a removeAt(0). La matriz no debe estar vacía. Si el array puede estar vacío, llame a isEmpty() antes de llamar a esta función.
Véase también removeAt() y removeLast().
void QJsonArray::removeLast()
Elimina el último elemento de la matriz. Llamar a esta función es equivalente a llamar a removeAt(size() - 1). La matriz no debe estar vacía. Si la matriz puede estar vacía, llame a isEmpty() antes de llamar a esta función.
Véase también removeAt() y removeFirst().
void QJsonArray::replace(qsizetype i, const QJsonValue &value)
Sustituye el elemento en la posición de índice i por value. i debe ser una posición de índice válida en la matriz (es decir, 0 <= i < size()).
Véase también operator[]() y removeAt().
qsizetype QJsonArray::size() const
Devuelve el número de valores almacenados en la matriz.
[noexcept] void QJsonArray::swap(QJsonArray &other)
Intercambia esta matriz con other. Esta operación es muy rápida y nunca falla.
QJsonValue QJsonArray::takeAt(qsizetype i)
Elimina el elemento en la posición de índice i y lo devuelve. i debe ser una posición de índice válida en la matriz (es decir, 0 <= i < size()).
Si no utiliza el valor devuelto, removeAt() es más eficiente.
Véase también removeAt().
QVariantList QJsonArray::toVariantList() const
Convierte este objeto en un QVariantList.
Devuelve el mapa creado.
QJsonArray QJsonArray::operator+(const QJsonValue &value) const
Devuelve una matriz que contiene todos los elementos de esta matriz seguidos de value.
Véase también operator+=().
QJsonArray &QJsonArray::operator+=(const QJsonValue &value)
Añade value a la matriz y devuelve una referencia a la propia matriz.
Véase también append() y operator<<().
QJsonArray &QJsonArray::operator<<(const QJsonValue &value)
Añade value a la matriz y devuelve una referencia a la propia matriz.
Véase también operator+=() y append().
[noexcept] QJsonArray &QJsonArray::operator=(QJsonArray &&other)
Mover-asigna other a este array.
[noexcept] QJsonArray &QJsonArray::operator=(const QJsonArray &other)
Asigna other a esta matriz.
QJsonValueRef QJsonArray::operator[](qsizetype i)
Devuelve el valor en la posición de índice i como una referencia modificable. i debe ser una posición de índice válida en la matriz (es decir, 0 <= i < size()).
El valor devuelto es del tipo QJsonValueRef, una clase auxiliar para QJsonArray y QJsonObject. Cuando se obtiene un objeto de tipo QJsonValueRef, se puede utilizar como si fuera una referencia a un QJsonValue. Si se le asigna, la asignación se aplicará al carácter en el QJsonArray de QJsonObject del que se obtuvo la referencia.
Véase también at().
QJsonValue QJsonArray::operator[](qsizetype i) const
Igual que at().
Se trata de una función sobrecargada.
No miembros relacionados
[noexcept] bool operator!=(const QJsonArray &lhs, const QJsonArray &rhs)
Devuelve true si la matriz lhs no es igual a rhs, false en caso contrario.
[noexcept] bool operator==(const QJsonArray &lhs, const QJsonArray &rhs)
Devuelve true si la matriz lhs es igual a rhs, false en caso contrario.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.