QJsonObject object = {{"name", "John"}, {"age", 30}, {"city", "New York"}}; QJsonObject::const_iterator it; for (it = object.constBegin(); it != object.constEnd(); ++it) { QString key = it.key(); QJsonValue value = it.value(); qDebug() << key << ":" << value; }
bool keyExists(QString key, const QJsonObject& object) { return object.constEnd() != object.find(key); }In both examples, we are using the Qt library's QJsonObject class, which is part of the Qt Core module.