QJsonObject Class

QJsonObjectクラスは、JSONオブジェクトをカプセル化します。詳細...

ヘッダー #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

Qt-style synonym forQJsonObject::const_iterator.

QJsonObject::Iterator

Qt-style synonym forQJsonObject::iterator.

QJsonObject::key_type

QString 。STL との互換性のために提供される。

QJsonObject::mapped_type

QJsonValue 。STL との互換性のために提供される。

QJsonObject::size_type

qsizetypeの型定義。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)

Move-construct QJsonObject fromother.

[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 を持つ項目を指すイテレータを返す。

マップにキー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 が指す (key, value) ペアをマップから削除し、マップの次の項目へのイテレータを返します。

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

オブジェクトに格納されている (key, value) ペアの数を返します。

[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 となる。

QJsonValue およびQJsonValue::isUndefined()も参照して ください。

QJsonValue QJsonObject::value(QLatin1StringView key) const

これはオーバーロードされた関数である。

QJsonValue QJsonObject::value(QStringView key) const

これはオーバーロードされた関数である。

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

Move-このオブジェクトにother を割り当てる。

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

このオブジェクトにother を割り当てる。

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

key の値への参照を返す。オブジェクト内にキーkey を持つ値がない場合、QJsonValue::Null の値で値が作成され、返される。

戻り値は、QJsonArray およびQJsonObject のヘルパー・クラスである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 と等しくなければtrue を、そうでなければfalse を返す。

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

lhs オブジェクトがrhs と等しければtrue を、そうでなければfalse を返す。

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