QJsonObject Class

QJsonObject 클래스는 JSON 객체를 캡슐화합니다. 더 보기...

Header: #include <QJsonObject>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

이 클래스는 동등 비교가 가능합니다.

이 클래스는 QJsonValue 및 QJsonValueConstRef와 동등 비교 가능합니다.

참고: 이 클래스의 모든 함수는 재인용됩니다.

공용 유형

공용 함수

QJsonObject()
QJsonObject(std::initializer_list<std::pair<QString, QJsonValue>> args)
QJsonObject(const QJsonObject &other)
QJsonObject(QJsonObject &&other)
~QJsonObject()
QJsonObject::iterator begin()
QJsonObject::const_iterator begin() const
QJsonObject::const_iterator constBegin() const
QJsonObject::const_iterator constEnd() const
QJsonObject::const_iterator constFind(const QString &key) const
QJsonObject::const_iterator constFind(QLatin1StringView key) const
QJsonObject::const_iterator constFind(QStringView key) const
bool contains(const QString &key) const
bool contains(QLatin1StringView key) const
bool contains(QStringView key) const
qsizetype count() const
bool empty() const
QJsonObject::iterator end()
QJsonObject::const_iterator end() const
QJsonObject::iterator erase(QJsonObject::iterator it)
QJsonObject::iterator find(const QString &key)
QJsonObject::iterator find(QLatin1StringView key)
QJsonObject::iterator find(QStringView key)
QJsonObject::const_iterator find(QLatin1StringView key) const
QJsonObject::const_iterator find(QStringView key) const
QJsonObject::const_iterator find(const QString &key) const
QJsonObject::iterator insert(const QString &key, const QJsonValue &value)
QJsonObject::iterator insert(QLatin1StringView key, const QJsonValue &value)
QJsonObject::iterator insert(QStringView key, const QJsonValue &value)
bool isEmpty() const
QStringList keys() const
qsizetype length() const
void remove(const QString &key)
void remove(QLatin1StringView key)
void remove(QStringView key)
qsizetype size() const
void swap(QJsonObject &other)
QJsonValue take(const QString &key)
QJsonValue take(QLatin1StringView key)
QJsonValue take(QStringView key)
QVariantHash toVariantHash() const
QVariantMap toVariantMap() const
QJsonValue value(const QString &key) const
QJsonValue value(QLatin1StringView key) const
QJsonValue value(QStringView key) const
QJsonObject &operator=(QJsonObject &&other)
QJsonObject &operator=(const QJsonObject &other)
QJsonValueRef operator[](const QString &key)
QJsonValue operator[](const QString &key) const
QJsonValueRef operator[](QLatin1StringView key)
QJsonValueRef operator[](QStringView key)
QJsonValue operator[](QLatin1StringView key) const
QJsonValue operator[](QStringView key) const

정적 공용 멤버

QJsonObject fromVariantHash(const QVariantHash &hash)
QJsonObject fromVariantMap(const QVariantMap &map)
bool operator!=(const QJsonObject &lhs, const QJsonObject &rhs)
bool operator==(const QJsonObject &lhs, const QJsonObject &rhs)

상세 설명

JSON 객체는 키 값 쌍의 목록으로, 키는 고유 문자열이고 값은 QJsonValue 로 표현됩니다.

QJsonObject는 QVariantMap 로 변환할 수 있습니다. size(), insert() 및 remove() 항목을 사용하여 (키, 값) 쌍의 수를 쿼리하고 표준 C++ 이터레이터 패턴을 사용하여 해당 내용을 반복할 수 있습니다.

QJsonObject는 암시적으로 공유되는 클래스이며, 수정되지 않는 한 생성된 문서와 데이터를 공유합니다.

QJsonDocument 를 통해 객체를 텍스트 기반 JSON으로 변환하거나 변환할 수 있습니다.

Qt의 JSON 지원게임 저장 및 로드도참조하세요 .

멤버 유형 문서

QJsonObject::ConstIterator

QJsonObject::const_iterator 의 Qt 스타일 동의어.

QJsonObject::Iterator

QJsonObject::iterator 의 Qt 스타일 동의어.

QJsonObject::key_type

QString. STL 호환성을 위해 제공됩니다.

QJsonObject::mapped_type

QJsonValue. STL 호환성을 위해 제공됩니다.

QJsonObject::size_type

qsizetype의 경우 Typedef. STL 호환성을 위해 제공됩니다.

멤버 함수 문서

QJsonObject::QJsonObject()

빈 JSON 객체를 생성합니다.

isEmpty()도 참조하세요 .

QJsonObject::QJsonObject(std::initializer_list<std::pair<QString, QJsonValue>> args)

args 초기화 목록에서 초기화된 QJsonObject 인스턴스를 구축합니다. 예를 들어

QJsonObject object
{
    {"property1", 1},
    {"property2", 2}
};

[noexcept] QJsonObject::QJsonObject(const QJsonObject &other)

other 의 복사본을 만듭니다.

QJsonObject는 암시적으로 공유되므로 개체가 수정되지 않는 한 복사본은 얕습니다.

[noexcept] QJsonObject::QJsonObject(QJsonObject &&other)

이동 - other 에서 QJsonObject를 생성합니다.

[noexcept] QJsonObject::~QJsonObject()

개체를 파괴합니다.

QJsonObject::iterator QJsonObject::begin()

객체의 첫 번째 항목을 가리키는 STL 스타일 이터레이터를 반환합니다.

constBegin() 및 end()도 참조하세요 .

QJsonObject::const_iterator QJsonObject::begin() const

과부하가 걸린 기능입니다.

QJsonObject::const_iterator QJsonObject::constBegin() const

객체의 첫 번째 항목을 가리키는 상수 STL 스타일 이터레이터를 반환합니다.

begin() 및 constEnd()도 참조하세요 .

QJsonObject::const_iterator QJsonObject::constEnd() const

객체의 마지막 항목 뒤에 있는 가상의 항목을 가리키는 상수 STL 스타일 이터레이터를 반환합니다.

constBegin() 및 end()도 참조하세요 .

QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const

맵에서 키가 key 인 항목을 가리키는 const 이터레이터를 반환합니다.

맵에 키가 key 인 항목이 없는 경우 함수는 constEnd()을 반환합니다.

QJsonObject::const_iterator QJsonObject::constFind(QLatin1StringView key) const

과부하가 걸린 기능입니다.

QJsonObject::const_iterator QJsonObject::constFind(QStringView key) const

과부하가 걸린 기능입니다.

bool QJsonObject::contains(const QString &key) const

객체에 키 key 가 포함된 경우 true 를 반환합니다.

insert(), remove(), take()도 참조하세요 .

bool QJsonObject::contains(QLatin1StringView key) const

과부하가 걸린 기능입니다.

bool QJsonObject::contains(QStringView key) const

과부하가 걸린 기능입니다.

qsizetype QJsonObject::count() const

이 함수는 과부하된 함수입니다.

size()와 동일합니다.

bool QJsonObject::empty() const

이 함수는 STL 호환성을 위해 제공됩니다. isEmpty ()와 동일하며, 객체가 비어 있으면 true 을 반환하고 그렇지 않으면 false 을 반환합니다.

QJsonObject::iterator QJsonObject::end()

객체의 마지막 항목 뒤에 있는 가상의 항목을 가리키는 STL 스타일 이터레이터를 반환합니다.

begin() 및 constEnd()도 참조하세요 .

QJsonObject::const_iterator QJsonObject::end() const

과부하가 걸린 기능입니다.

QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it)

반복자 it 가 가리키는 (키, 값) 쌍을 맵에서 제거하고 반복자를 맵의 다음 항목으로 반환합니다.

remove()도 참조하세요 .

QJsonObject::iterator QJsonObject::find(const QString &key)

맵에서 key 키를 가진 항목을 가리키는 이터레이터를 반환합니다.

맵에 키가 key 인 항목이 없는 경우 이 함수는 end()을 반환합니다.

QJsonObject::iterator QJsonObject::find(QLatin1StringView key)

과부하가 걸린 기능입니다.

QJsonObject::iterator QJsonObject::find(QStringView key)

과부하가 걸린 기능입니다.

QJsonObject::const_iterator QJsonObject::find(QLatin1StringView key) const

과부하가 걸린 기능입니다.

QJsonObject::const_iterator QJsonObject::find(QStringView key) const

과부하가 걸린 기능입니다.

QJsonObject::const_iterator QJsonObject::find(const QString &key) const

과부하가 걸린 기능입니다.

[static] QJsonObject QJsonObject::fromVariantHash(const QVariantHash &hash)

변형 해시 hashQJsonObject 로 변환합니다.

hash 의 키는 JSON 객체의 키로 사용되며 QVariant 값은 JSON 값으로 변환됩니다.

참고: QVariant 에서의 변환은 완전히 무손실 변환이 아닙니다. 자세한 내용은 QJsonValue::fromVariant()의 문서를 참조하세요.

fromVariantMap(), toVariantHash() 및 QJsonValue::fromVariant()도 참조하세요 .

[static] QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map)

변형 맵 mapQJsonObject 으로 변환합니다.

map 의 키는 JSON 객체의 키로 사용되며 QVariant 값은 JSON 값으로 변환됩니다.

참고: QVariant 에서의 변환은 완전히 무손실 변환이 아닙니다. 자세한 내용은 QJsonValue::fromVariant()의 문서를 참조하세요.

fromVariantHash(), toVariantMap() 및 QJsonValue::fromVariant()도 참조하세요 .

QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value)

키가 key 이고 값이 value 인 새 항목을 삽입합니다.

키가 key 인 항목이 이미 있는 경우 해당 항목의 값은 value 으로 바뀝니다.

삽입된 항목을 가리키는 이터레이터를 반환합니다.

값이 QJsonValue::Undefined 인 경우 객체에서 키가 제거됩니다. 그러면 반환된 이터레이터는 end()를 가리킵니다.

remove(), take(), QJsonObject::iterator, 및 end()도 참조하세요 .

QJsonObject::iterator QJsonObject::insert(QLatin1StringView key, const QJsonValue &value)

과부하가 걸린 기능입니다.

QJsonObject::iterator QJsonObject::insert(QStringView key, const QJsonValue &value)

과부하가 걸린 기능입니다.

bool QJsonObject::isEmpty() const

객체가 비어 있으면 true 을 반환합니다. 이는 size() == 0과 동일합니다.

size()도 참조하세요 .

QStringList QJsonObject::keys() const

이 객체에 있는 모든 키의 목록을 반환합니다.

목록은 알파벳순으로 정렬됩니다.

qsizetype QJsonObject::length() const

이 함수는 과부하된 함수입니다.

size()와 동일합니다.

void QJsonObject::remove(const QString &key)

개체에서 key 을 제거합니다.

insert() 및 take()도 참조하세요 .

void QJsonObject::remove(QLatin1StringView key)

과부하가 걸린 기능입니다.

void QJsonObject::remove(QStringView key)

과부하가 걸린 기능입니다.

qsizetype QJsonObject::size() const

객체에 저장된 (키, 값) 쌍의 수를 반환합니다.

[noexcept] void QJsonObject::swap(QJsonObject &other)

이 객체를 other 로 바꿉니다. 이 작업은 매우 빠르며 실패하지 않습니다.

QJsonValue QJsonObject::take(const QString &key)

객체에서 key 을 제거합니다.

key 에서 참조한 값을 포함하는 QJsonValue 을 반환합니다. key 가 객체에 포함되지 않은 경우 반환되는 QJsonValueQJsonValue::Undefined 입니다.

insert(), remove() 및 QJsonValue도 참조하세요 .

QJsonValue QJsonObject::take(QLatin1StringView key)

과부하가 걸린 기능입니다.

QJsonValue QJsonObject::take(QStringView key)

과부하가 걸린 기능입니다.

QVariantHash QJsonObject::toVariantHash() const

이 객체를 QVariantHash 로 변환합니다.

생성된 해시를 반환합니다.

toVariantMap()도 참조하세요 .

QVariantMap QJsonObject::toVariantMap() const

이 객체를 QVariantMap 로 변환합니다.

생성된 지도를 반환합니다.

toVariantHash()도 참조하세요 .

QJsonValue QJsonObject::value(const QString &key) const

key 키의 값을 나타내는 QJsonValue 을 반환합니다.

키가 존재하지 않는 경우 반환되는 QJsonValueQJsonValue::Undefined 입니다.

QJsonValueQJsonValue::isUndefined()도 참조하세요 .

QJsonValue QJsonObject::value(QLatin1StringView key) const

과부하가 걸린 기능입니다.

QJsonValue QJsonObject::value(QStringView key) const

과부하가 걸린 기능입니다.

[noexcept] QJsonObject &QJsonObject::operator=(QJsonObject &&other)

이동 - 이 개체에 other 를 할당합니다.

[noexcept] QJsonObject &QJsonObject::operator=(const QJsonObject &other)

other 이 객체에 할당합니다.

QJsonValueRef QJsonObject::operator[](const QString &key)

key 값에 대한 참조를 반환합니다. 객체에 key 키가 있는 값이 없는 경우 QJsonValue::Null 값으로 값을 생성한 다음 반환합니다.

반환 값은 QJsonArrayQJsonObject 에 대한 헬퍼 클래스인 QJsonValueRef 유형입니다. QJsonValueRef 유형의 객체를 가져오면 QJsonValue 에 대한 참조인 것처럼 사용할 수 있습니다. 이 객체에 할당하면 참조를 가져온 QJsonArray 또는 QJsonObject 의 요소에 할당이 적용됩니다.

value()도 참조하세요 .

QJsonValue QJsonObject::operator[](const QString &key) const

key 키의 값을 나타내는 QJsonValue 를 반환합니다.

value()와 같은 역할을 합니다.

키가 존재하지 않는 경우 반환되는 QJsonValueQJsonValue::Undefined 입니다.

value(), QJsonValue, QJsonValue::isUndefined()도 참조하세요 .

QJsonValueRef QJsonObject::operator[](QLatin1StringView key)

과부하가 걸린 기능입니다.

QJsonValueRef QJsonObject::operator[](QStringView key)

과부하가 걸린 기능입니다.

QJsonValue QJsonObject::operator[](QLatin1StringView key) const

과부하가 걸린 기능입니다.

QJsonValue QJsonObject::operator[](QStringView key) const

과부하가 걸린 기능입니다.

관련 비회원

[noexcept] bool operator!=(const QJsonObject &lhs, const QJsonObject &rhs)

lhs 객체가 rhs, false 과 같지 않은 경우 true 을 반환합니다.

[noexcept] bool operator==(const QJsonObject &lhs, const QJsonObject &rhs)

lhs 객체가 rhs, false 과 같으면 true 을 반환합니다.

© 2025 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.