当前位置: 首页>>代码示例>>C++>>正文


C++ JsonDataAccess类代码示例

本文整理汇总了C++中JsonDataAccess的典型用法代码示例。如果您正苦于以下问题:C++ JsonDataAccess类的具体用法?C++ JsonDataAccess怎么用?C++ JsonDataAccess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JsonDataAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QVariant

//write out
void Frontend::saveConfigToJson(QString file) {
	QVariantMap data;
	int i;

	data["device"] = m_controllers[0].device;

	QVariantList buttons;

	for(i=0;i<16;++i) {
		buttons.append(QVariant(m_controllers[0].buttons[i]));
	}

	data["buttons"] = QVariant(buttons);

	QVariantList gamepad;

	for(i=0;i<16;++i) {
		gamepad.append(QVariant(m_controllers[0].gamepad[i]));
	}

	data["gamepad"] = QVariant(gamepad);

	// Create a JsonDataAccess object and save the data to the file
	JsonDataAccess jda;
	jda.save(QVariant(data), file);
}
开发者ID:CatalystG,项目名称:pcsx-rearmed-cascades,代码行数:27,代码来源:frontend.cpp

示例2: parse

bool LoginReply::parse(const QByteArray& data)
{
	JsonDataAccess jsonObject;
	QVariant node = jsonObject.loadFromBuffer(data);
	if (jsonObject.hasError()) {
		qWarning() << "error converting JSON data: " << jsonObject.error().errorMessage();
	} else {
		qDebug() << "before parse: " << QString(data);
		QVariantMap map = node.value<QVariantMap>();
		if (map["status"].toString() == "OK") {
			m_status = true;
			m_sessionKey = map["sessionKey"].toString();
			QVariantList friendList = map["friends"].value<QVariantList>();
			for (int i = 0; i < friendList.size(); i++) {
				m_ppIds.append(friendList[i].toString());
			}
			QVariantList pinList = map["pins"].value<QVariantList>();
			for (int i = 0; i < pinList.size(); i++) {
				m_pins.append(pinList[i].toString());
			}

			return true;
		}
	}

	return false;
}
开发者ID:Najibsaurus,项目名称:friendmap,代码行数:27,代码来源:LoginReply.cpp

示例3: onError

void NetworkBus::onLineIsOpenFinished(QNetworkReply* reply){
	if(reply->error() != QNetworkReply::NoError){
		m_error = QString::fromUtf8("线路开通数据请求错误,请检查网络后重试!");
		onError();
		reply->deleteLater();
		return;
	}else{
		JsonDataAccess jda; // at are you
		const QVariant qtData = jda.loadFromBuffer(reply->readAll());
		// TODO if qtData has some error

		const QVariantMap map = qtData.toMap();
		const QString msg = map.values("msg").value(0).toString();
		const QString success = map.values("success").value(0).toString();
		if(success != "true" || msg != "ok"){
			m_error = QString::fromUtf8("线路开通返回失败,请检查网络后重试!");
			onError();
			return;
		}
		const QVariantList data = map["data"].toList();
		m_eid = data.at(0).toMap().value("eid").toString();
		m_isopen = data.at(0).toMap().value("isopen").toInt();
		qDebug() << "isOpen:" << m_isopen << "  eid:" << m_eid << "\n";
		reply->deleteLater();
		this->get_online_gps();
	}
}
开发者ID:codingkiller,项目名称:kumike2,代码行数:27,代码来源:network.cpp

示例4: buffer

void QBNetwork::onRequestUsers() {
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
	if (reply) {
		const int available = reply->bytesAvailable();
		if (available > 0) {
			const QByteArray buffer(reply->readAll());
			QString response = QString::fromUtf8(buffer);

			JsonDataAccess jda;
			QVariant qtData = jda.loadFromBuffer(response);
			if (jda.hasError()) {
				const DataAccessError err = jda.error();
				emit error(
						tr("Error converting JSON data: %1").arg(
								err.errorMessage()));
			} else {
				emit usersReceived(response);
			}
		} else {
			emit error("Wrong reply for request users request");
		}
		reply->deleteLater();
	} else {
		emit error("Wrong reply for request users request");
	}

	disconnectFromAll();
}
开发者ID:QuickBlox,项目名称:quickblox-blackberry10-sdk,代码行数:28,代码来源:QBNetwork.cpp

示例5: parse

bool GetLocationsReply::parse(const QByteArray& data)
{
    JsonDataAccess jsonObject;
    QVariant node = jsonObject.loadFromBuffer(data);
    if (jsonObject.hasError()) {
        qWarning() << "error converting JSON data: " << jsonObject.error().errorMessage();
    } else {
        qDebug() << "before parse: " << QString(data);
        QVariantMap map = node.value<QVariantMap>();
        if (map["status"].toString() == "OK") {
            m_status = true;
            QVariantList friendList = map["friends"].value<QVariantList>();
            for (int i = 0; i < friendList.size(); i++) {
                QString friendStr = friendList[i].toString();
                QStringList fields = friendStr.split(",");
                // if incorrect number of fields, stop parsing
                if (fields.size() != 4) return false;
                QString ppId = fields.at(0);
                double x = fields.at(1).toDouble();
                double y = fields.at(2).toDouble();
                int visibility = fields.at(3).toInt();
                m_friends.append(User(ppId, x, y, visibility));
            }

            return true;
        }
    }

    return false;
}
开发者ID:yuguang,项目名称:friendmap,代码行数:30,代码来源:GetLocationsReply.cpp

示例6: loadConfigFromJson

//load data from json into controllers
//{ "device" : int,
//	"buttons": [ int, int, int, ..., 16]
//}
int Frontend::loadConfigFromJson(QString file) {
	JsonDataAccess jda;
	int i;

	QVariantMap data = jda.load(file).toMap();

	if(data.isEmpty()){
		return -1;
	}

	m_controllers[0].device = data["device"].toInt();

	if(data["buttons"].isValid()){
		for(i=0;i<16;++i) {
			m_controllers[0].buttons[i] = data["buttons"].toList()[i].toInt();
		}
	}

	if(data["gamepad"].isValid()){
		for(i=0;i<16;++i) {
			m_controllers[0].gamepad[i] = data["gamepad"].toList()[i].toInt();
		}
	}

	return 0;
}
开发者ID:CatalystG,项目名称:pcsx-rearmed-cascades,代码行数:30,代码来源:frontend.cpp

示例7: removeAccountAt

void AccountList::removeAccountAt(int i)
{
	JsonDataAccess jda;
	QVariantList list = jda.load(this->file).value<QVariantList>();
	list.removeAt(i);
	jda.save(QVariant(list), this->file);
	loadAccounts();
}
开发者ID:sgeisler,项目名称:PassSafe,代码行数:8,代码来源:AccountList.cpp

示例8: opendir

void RetroArch::findCores()
{
   DIR *dirp;
   struct dirent* direntp;
   int count=0, i=0;

   dirp = opendir(g_settings.libretro);
   if( dirp != NULL )
   {
      for(;;)
      {
         direntp = readdir( dirp );
         if( direntp == NULL ) break;
         count++;
      }
      fflush(stdout);
      rewinddir(dirp);

      if(count==2)
      {
         printf("No Cores Found");fflush(stdout);
      }

      coreList = (char**)malloc(count*sizeof(char*));
      count = 0;

      for(;;)
      {
         direntp = readdir( dirp );
         if( direntp == NULL ) break;
         coreList[count++] = strdup((char*)direntp->d_name);
      }

      //Load info for Cores
      JsonDataAccess jda;

      coreInfo = jda.load("app/native/assets/coreInfo.json").toMap();

      Option *tmp;

      //Populate DropDown
      for (i = 2; i < count; ++i)
      {
         qDebug() << GET_CORE_INFO(i, "display_name");

         tmp = Option::create().text(GET_CORE_INFO(i, "display_name"))
                               .value(i);

         coreSelection->add(tmp);
      }
   }

   closedir(dirp);
}
开发者ID:penkamaster,项目名称:RetroArch,代码行数:54,代码来源:RetroArch-Cascades.cpp

示例9: qDebug

void VolumeRequest::requestResponse(QByteArray& result) {
	qDebug() << " DataRequest::requestResponse QString result=" << QString(result);
	
	JsonDataAccess jda;
	QVariant jsonVariant = jda.loadFromBuffer( QString(result));
	
	QVariantMap map = jsonVariant.toMap();
	QVariantList records = map.value("records").toList();
	
	emit success(mutateRecords(records));
}
开发者ID:adozenlines,项目名称:BES10-Cascades,代码行数:11,代码来源:VolumeRequest.cpp

示例10: GroupDataModel

void RocknRoll::parseJSON() {
	GroupDataModel *model = new GroupDataModel(QStringList() << "artist" << "song" << "genre" << "year");

	JsonDataAccess jda;
	QVariant list = jda.load("dummy.json");

	model->insertList(list.value<QVariantList>());

	ListView *listView = new ListView();
	listView->setDataModel(model);
}
开发者ID:sanjayasl,项目名称:RocknRoll,代码行数:11,代码来源:RocknRoll.cpp

示例11: addItem

void HubCache::addItem(QVariantMap itemMap)
{
    _items.append(itemMap);
    _lastItemId++;

    _settings->setValue(_lastItemIdKey, _lastItemId);
    _settings->setValue(_itemsKey, _items);

    JsonDataAccess jda;
    jda.save(_items, "data/hub_items.json");
    jda.deleteLater();
}
开发者ID:NemOry,项目名称:FacebookMessengerClientHeadless,代码行数:12,代码来源:HubCache.cpp

示例12: setShouldShowFunctions

void ApplicationUI::startLevel(const QVariantList &indexPath)
{
	if (!m_gamePage) {
		QmlDocument *qml = QmlDocument::create("asset:///Game.qml").parent(this);
		qml->setContextProperty("_app", this);
		m_gamePage = qml->createRootObject<Page>();
		m_progressAnimation = m_gamePage->findChild<SequentialAnimation*>("progressAnimation");
	}

	if (indexPath.count() > 0)
		m_levelIndex = indexPath[0].toInt();
	else
		m_levelIndex = 0; // Uhoh?

	m_phase = COMPILE;
	m_selectedFunction = 0;
	setShouldShowFunctions(false);
	setIsInFunction(-1);
	Container *compileContainer = m_gamePage->findChild<Container*>("compilePhaseContainer");
	compileContainer->setVisible(true);

	m_gamePage->findChild<Container*>("tutorial1Container")->setProperty("state", 0);
	m_gamePage->findChild<Container*>("tutorial2Container")->setProperty("state", 0);
	m_gamePage->findChild<Container*>("tutorial3Container")->setProperty("state", 0);
	m_gamePage->findChild<Container*>("progressBar")->setTranslationX(0);
	m_gamePage->findChild<Container*>("creditsContainer")->setVisible(false);

	m_gamePage->findChild<Button*>("menuButton")->setText("Continue");
	m_gamePage->findChild<Container*>("menuContainer")->setVisible(false);

	QVariantMap levelInfo = m_levelList->dataModel()->data(indexPath).toMap();
	QString levelPath = levelInfo["level"].toString();
	JsonDataAccess jda;
	qDebug() << "Attempting to load " << levelPath;
	QVariantMap levelData = jda.load(levelPath).toMap();
	if (jda.hasError()) {
		bb::data::DataAccessError error = jda.error();
		qFatal("JSON loading error: %d: %s", error.errorType(), qPrintable(error.errorMessage()));
		return;
	} else {
		qDebug() << "JSON data loaded OK!";
	}

	setupLevel(levelData);
	setupQueue();

	m_navigationPane->push(m_gamePage);

	m_timer.setInterval(2000);

	m_gamePage->findChild<Container*>("compileFunctionContainer")->setVisible(m_functionCount > 0);
	drawSelectedFunction();
}
开发者ID:jnicholl,项目名称:AIMaze,代码行数:53,代码来源:applicationui.cpp

示例13: qDebug

void QBNetwork::login(QString userName, QString userPassword) {
	qDebug() << "login userName " << userName << " userPassword " << userPassword;
	setLoadAction(true);
	QBLOX_LOGIN = userName;
	QBLOX_PASSWORD = userPassword;

	const QUrl url(QBLOX_API_SERVER + "session.json");

	QString timestamp = QString::number(QBUtils::getTimestampUTCMs());

	QString postParam = "application_id=";
	postParam += QBLOX_APP_ID;
	postParam += "&auth_key=";
	postParam += QBLOX_AUTH_KEY;
	postParam += "&nonce=";
	postParam += timestamp;
	postParam += "&timestamp=";
	postParam += timestamp;
	postParam += "&user[login]=";
	postParam += QBLOX_LOGIN;
	postParam += "&user[password]=";
	postParam += QBLOX_PASSWORD;

	QString signature = hmac_sha1(postParam, QBLOX_AUTH_SECRET);

	QVariantMap qUser;
	qUser["login"] = QBLOX_LOGIN;
	qUser["password"] = QBLOX_PASSWORD;

	QVariantMap qSettings;
	qSettings["application_id"] = QBLOX_APP_ID;
	qSettings["auth_key"] = QBLOX_AUTH_KEY;
	qSettings["nonce"] = timestamp;
	qSettings["timestamp"] = timestamp;
	qSettings["signature"] = signature;
	qSettings["user"] = qUser;

	QVariant setData = QVariant(qSettings);
	QString outRequest = "";
	JsonDataAccess jda;
	jda.saveToBuffer(setData, &outRequest);

	QNetworkRequest request(url);
	request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
	request.setRawHeader("QuickBlox-REST-API-Version", "0.1.0");

	QNetworkReply* reply = m_networkAccessManager->post(request,
			outRequest.toAscii());
	connect(reply, SIGNAL(finished()), this, SLOT(onRequestSessionWithLogin()));
	connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this,
			SLOT(onNetworkError(QNetworkReply::NetworkError)));
}
开发者ID:QuickBlox,项目名称:quickblox-blackberry10-sdk,代码行数:52,代码来源:QBNetwork.cpp

示例14: loadAccounts

void AccountList::loadAccounts()
{
	this->accounts = QList<Account>();
	JsonDataAccess jda;
	QVariantList list = jda.load(this->file).value<QVariantList>();
	bool* ok = new bool;
	for(int i = 0; i < list.size(); i++)
	{
		accounts.append(Account(list.at(i).toMap().value("name").toString(), list.at(i).toMap().value("start").toInt(ok), list.at(i).toMap().value("stop").toInt(ok)));
	}
	delete(ok);

}
开发者ID:sgeisler,项目名称:PassSafe,代码行数:13,代码来源:AccountList.cpp

示例15: editAccount

void AccountList::editAccount(int i, QString name, int start, int stop)
{
	JsonDataAccess jda;
	QVariantList list = jda.load(this->file).value<QVariantList>();
	QVariantMap acc;
	acc["name"] = QVariant(name);
	acc["start"] = QVariant(start);
	acc["stop"] = QVariant(stop);
	list.removeAt(i);
	list.insert(i, QVariant(acc));
	jda.save(QVariant(list), this->file);
	loadAccounts();
}
开发者ID:sgeisler,项目名称:PassSafe,代码行数:13,代码来源:AccountList.cpp


注:本文中的JsonDataAccess类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。