这篇教程C++ toJson函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中toJson函数的典型用法代码示例。如果您正苦于以下问题:C++ toJson函数的具体用法?C++ toJson怎么用?C++ toJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了toJson函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: JsonObjectJsonObject*SamiAccessToken::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pAccess_tokenKey = new JsonString(L"access_token"); pJsonObject->Add(pAccess_tokenKey, toJson(getPAccessToken(), "String", "")); JsonString *pRefresh_tokenKey = new JsonString(L"refresh_token"); pJsonObject->Add(pRefresh_tokenKey, toJson(getPRefreshToken(), "String", "")); JsonString *pExpire_inKey = new JsonString(L"expire_in"); pJsonObject->Add(pExpire_inKey, toJson(getPExpireIn(), "Integer", "")); JsonString *pExpires_inKey = new JsonString(L"expires_in"); pJsonObject->Add(pExpires_inKey, toJson(getPExpiresIn(), "Integer", "")); JsonString *pScopeKey = new JsonString(L"scope"); pJsonObject->Add(pScopeKey, toJson(getPScope(), "String", "array")); return pJsonObject;}
开发者ID:clinique,项目名称:netatmo-swagger-api,代码行数:28,
示例2: toJsonvoid toJson(json::ostream_writer_t& os, const QVariant& var){ QVariant::Type type = var.type(); switch(type) { case QVariant::Map: { const QVariantMap map = var.toMap(); os.object_start(); for (QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it) { os.new_string(it.key().toStdString().c_str()); toJson(os, it.value()); } os.object_end(); } break; case QVariant::List: case QVariant::StringList: { const QVariantList list = var.toList(); os.array_start(); for (int i = 0; i < list.size(); i++) { toJson(os, list.at(i)); } os.array_end(); } break; case QVariant::String: { os.new_string(var.toString().toStdString().c_str()); } break; case QVariant::Bool: { os.new_bool(var.toBool()); } break; default: if (var.canConvert< double >()) { os.new_double(var.toDouble()); break; } os.new_string("unsupported yet!"); break; }}
开发者ID:catedrasaes-umu,项目名称:corbasim,代码行数:58,
示例3: imuToJsonJson::Value imuToJson(const IMUData& sample, timestamp_t start_time) { Json::Value sampleEntry(Json::objectValue); sampleEntry["gyro"] = toJson(sample.gyro); sampleEntry["acc"] = toJson(sample.acc); sampleEntry["gyroAcc"] = toJson(sample.gyroAcc); sampleEntry["attitude"] = toJson(sample.attitude); sampleEntry["timestamp"] = ((sample.timestamp - start_time) / std::chrono::microseconds(1)); sampleEntry["debugData"] = sample.jsonDebugData; return sampleEntry;}
开发者ID:deets,项目名称:balancebot-3000,代码行数:12,
示例4: JsonObjectJsonObject*SamiAlgorithm::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pProblem_typeKey = new JsonString(L"problem_type"); pJsonObject->Add(pProblem_typeKey, toJson(getPProblemType(), "String", "")); JsonString *pObjectiveKey = new JsonString(L"objective"); pJsonObject->Add(pObjectiveKey, toJson(getPObjective(), "String", "")); return pJsonObject;}
开发者ID:graphhopper,项目名称:directions-api-clients-route-optimization,代码行数:13,
示例5: JsonObjectJsonObject*SamiShipment::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "String", "")); JsonString *pNameKey = new JsonString(L"name"); pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); JsonString *pPriorityKey = new JsonString(L"priority"); pJsonObject->Add(pPriorityKey, toJson(getPPriority(), "Integer", "")); JsonString *pPickupKey = new JsonString(L"pickup"); pJsonObject->Add(pPickupKey, toJson(getPPickup(), "SamiStop", "")); JsonString *pDeliveryKey = new JsonString(L"delivery"); pJsonObject->Add(pDeliveryKey, toJson(getPDelivery(), "SamiStop", "")); JsonString *pSizeKey = new JsonString(L"size"); pJsonObject->Add(pSizeKey, toJson(getPSize(), "Integer", "array")); JsonString *pRequired_skillsKey = new JsonString(L"required_skills"); pJsonObject->Add(pRequired_skillsKey, toJson(getPRequiredSkills(), "String", "array")); JsonString *pAllowed_vehiclesKey = new JsonString(L"allowed_vehicles"); pJsonObject->Add(pAllowed_vehiclesKey, toJson(getPAllowedVehicles(), "String", "array")); return pJsonObject;}
开发者ID:graphhopper,项目名称:directions-api-clients-route-optimization,代码行数:31,
示例6: modeString/** * Expected input: * { * alg: "aes", * mode: "cbc", * key: key data, * iv: iv data (16 bytes), * input: data to encrypt or decrypt * } * * Good output: * { * output: data * } */Json::Value AES::crypt(const std::string & algorithm, Json::Value & args, bool isEncrypt) { if (!args.isMember("key")) { throw std::string("key missing"); } if (!args.isMember("input")) { throw std::string("input missing"); } if (!args.isMember("iv")) { throw std::string("iv missing"); } if (!args.isMember("mode")) { throw std::string("mode missing"); } std::string modeString( gsecrypto::util::lowerCaseRemoveDashes(args["mode"].asString())); if ("cbc" != modeString) { throw std::string("Only CBC currently supported"); } DataTracker input; getData(args["input"], input); DataTracker result(input.dataLen); if (input.dataLen == 0) { Json::Value toReturn; toReturn["output"] = toJson(result); return toReturn; } DataTracker keyBytes; getData(args["key"], keyBytes); DataTracker iv; getData(args["iv"], iv); int mode = SB_AES_CBC; AESParams params(*this, SB_AES_CBC, SB_AES_128_BLOCK_BITS, false); AESKey key(params, keyBytes); AESContext context(params, key, mode, iv); context.crypt(input, result, isEncrypt); Json::Value toReturn; toReturn["output"] = toJson(result); return toReturn;}
开发者ID:Angtrim,项目名称:WebWorks-Community-APIs,代码行数:64,
示例7: toJsonJson::Value toJson(dev::eth::BlockInfo const& _bi, BlockDetails const& _bd, UncleHashes const& _us, Transactions const& _ts){ Json::Value res = toJson(_bi); if (_bi) { res["totalDifficulty"] = toJS(_bd.totalDifficulty); res["uncles"] = Json::Value(Json::arrayValue); for (h256 h: _us) res["uncles"].append(toJS(h)); res["transactions"] = Json::Value(Json::arrayValue); for (unsigned i = 0; i < _ts.size(); i++) res["transactions"].append(toJson(_ts[i], std::make_pair(_bi.hash(), i), (BlockNumber)_bi.number)); } return res;}
开发者ID:Matt90o,项目名称:cpp-ethereum,代码行数:15,
示例8: switchvoidItemSerializer::toJson(std::ostream& out, const sserialize::Static::spatial::GeoShape& gs) const{ sserialize::spatial::GeoShapeType gst = gs.type(); out << "{/"t/":" << gst << ",/"v/":"; switch(gst) { case sserialize::spatial::GS_POINT: { auto gp = gs.get<sserialize::spatial::GS_POINT>(); out << "[" << gp->lat() << "," << gp->lon() << "]"; } break; case sserialize::spatial::GS_WAY: case sserialize::spatial::GS_POLYGON: { auto gw = gs.get<sserialize::spatial::GS_WAY>(); out << "["; if (gw->size()) { auto it(gw->cbegin()), end(gw->cend()); sserialize::Static::spatial::GeoPoint gp(*it); out << "[" << gp.lat() << "," << gp.lon() << "]"; for(++it; it != end; ++it) { gp = *it; out << ",[" << gp.lat() << "," << gp.lon() << "]"; } } out << "]"; } break; case sserialize::spatial::GS_MULTI_POLYGON: { out << "{"; auto gmw = gs.get<sserialize::spatial::GS_MULTI_POLYGON>(); if (gmw->innerPolygons().size()) { out << "/"inner/":"; toJson(out, gmw->innerPolygons()); out << ","; } out << "/"outer/":"; toJson(out, gmw->outerPolygons()); out << "}"; } break; default: break; } out << "}";}
开发者ID:dbahrdt,项目名称:oscar-web,代码行数:48,
示例9: Q_UNUSED//------------------------------------------------------------------------------// Name: toJson//------------------------------------------------------------------------------QByteArray QJsonDocument::toJson(JsonFormat format) const { Q_UNUSED(format); if(isArray()) { QString s = toJson(array(), format); return s.toUtf8(); } if(isObject()) { QString s = toJson(object(), format); return s.toUtf8(); } return QByteArray();}
开发者ID:Iv,项目名称:FlyHigh,代码行数:19,
示例10: JsonObjectJsonObject*SamiMeasurementValue::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pStart_timeKey = new JsonString(L"start_time"); pJsonObject->Add(pStart_timeKey, toJson(getPStartTime(), "Long", "")); JsonString *pValueKey = new JsonString(L"value"); pJsonObject->Add(pValueKey, toJson(getPValue(), "Float", "")); return pJsonObject;}
开发者ID:QuantiModo,项目名称:quantimodo-sdk-tizen,代码行数:16,
示例11: JsonObjectJsonObject*SamiStatus::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pCodeKey = new JsonString(L"code"); pJsonObject->Add(pCodeKey, toJson(getPCode(), "String", "")); JsonString *pInfoKey = new JsonString(L"info"); pJsonObject->Add(pInfoKey, toJson(getPInfo(), "String", "")); return pJsonObject;}
开发者ID:onlineconvert,项目名称:onlineconvert-api-sdk-tizen,代码行数:16,
示例12: switchQVariant AnimationEditor::ImageTableModel::data(const QModelIndex &index, int role) const { if (role == Qt::DecorationRole || role == Qt::DisplayRole) { int r = index.row(); int c = index.column(); auto slide = m_model.Images[r]; switch (c) { case 0: { auto img = slide.Image; if (!m_pixMaps.contains(slide.Image.toJson())) { m_pixMaps[img.toJson()] = SpriteSheetManager::getPixmap(img, m_projectPath); } return m_pixMaps[slide.Image.toJson()]; } case 1: { auto spriteSheet = m_projectPath + slide.Image.SpriteSheet; spriteSheet = spriteSheet.mid(spriteSheet.lastIndexOf('/') + 1); spriteSheet = spriteSheet.mid(0, spriteSheet.size() - 5); return spriteSheet; } case 2: return slide.Interval; } } return QVariant();}
开发者ID:wombatant,项目名称:wombat-studio,代码行数:28,
示例13: generate/*! * /brief Generate JSON string from QVariant * /param data QVariant with data * /param indent Identation of new lines * /return JSON string with data*/QByteArray generate(const QVariant &data, int indent){ Q_UNUSED(indent); auto document = QJsonDocument::fromVariant(data); return document.toJson(QJsonDocument::Indented);}
开发者ID:alekseysidorov,项目名称:vreen,代码行数:13,
示例14: setCursorvoid Canvas::drawLineTo(const QPoint &endPoint){ LayerPointer l = layers.selectedLayer(); if(l.isNull() || l->isLocked() || l->isHided()){ setCursor(Qt::ForbiddenCursor); return; } // setCursor(Qt::CrossCursor); updateCursor(brush_->width()); brush_->setSurface(l->imagePtr()); brush_->lineTo(endPoint); update(); QVariantMap start_j; start_j.insert("x", this->lastPoint.x()); start_j.insert("y", this->lastPoint.y()); QVariantMap end_j; end_j.insert("x", endPoint.x()); end_j.insert("y", endPoint.y()); QVariantMap map; map.insert("brush", QVariant(brushInfo())); map.insert("start", QVariant(start_j)); map.insert("end", QVariant(end_j)); map.insert("layer", QVariant(currentLayer())); map.insert("userid", QVariant(userId())); QVariantMap bigMap; bigMap.insert("info", map); bigMap.insert("action", "drawline"); QByteArray tmp = toJson(QVariant(bigMap)); emit sendData(tmp);}
开发者ID:pm19960106,项目名称:painttyWidget,代码行数:35,
示例15: JsonObjectJsonObject*SamiApiResponse::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pCodeKey = new JsonString(L"code"); pJsonObject->Add(pCodeKey, toJson(getPCode(), "Integer", "")); JsonString *pTypeKey = new JsonString(L"type"); pJsonObject->Add(pTypeKey, toJson(getPType(), "String", "")); JsonString *pMessageKey = new JsonString(L"message"); pJsonObject->Add(pMessageKey, toJson(getPMessage(), "String", "")); return pJsonObject;}
开发者ID:3dsorcery,项目名称:swagger-codegen,代码行数:16,
示例16: JsonObjectJsonObject*SamiInline_response_200_28::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pDataKey = new JsonString(L"data"); pJsonObject->Add(pDataKey, toJson(getPData(), "SamiVariable", "")); JsonString *pSuccessKey = new JsonString(L"success"); pJsonObject->Add(pSuccessKey, toJson(getPSuccess(), "Boolean", "")); return pJsonObject;}
开发者ID:QuantiModo,项目名称:quantimodo-sdk-tizen,代码行数:16,
示例17: JsonObjectJsonObject*SamiQuery::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pIncludeListKey = new JsonString(L"$includeList"); pJsonObject->Add(pIncludeListKey, toJson(getPIncludeList(), "String", "array")); JsonString *pIncludeKey = new JsonString(L"$include"); pJsonObject->Add(pIncludeKey, toJson(getPInclude(), "String", "array")); return pJsonObject;}
开发者ID:CloudBoost,项目名称:swagger,代码行数:16,
示例18: toJsonstd::string ResourceHandler::toJsonString(){ struct json_object * jobj = toJson(); std::string s = json_object_to_json_string(jobj); json_object_put(jobj); return s;}
开发者ID:22350,项目名称:luna-sysmgr,代码行数:7,
示例19: JsonObjectJsonObject*SamiQueueBody::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pDocumentKey = new JsonString(L"document"); pJsonObject->Add(pDocumentKey, toJson(getPDocument(), "SamiQueue", "")); JsonString *pKeyKey = new JsonString(L"key"); pJsonObject->Add(pKeyKey, toJson(getPKey(), "String", "")); return pJsonObject;}
开发者ID:CloudBoost,项目名称:swagger,代码行数:16,
示例20: JsonObjectJsonObject*SamiNATimeTableItem::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "Integer", "")); JsonString *pM_offsetKey = new JsonString(L"m_offset"); pJsonObject->Add(pM_offsetKey, toJson(getPMOffset(), "Integer", "")); return pJsonObject;}
开发者ID:wep4you,项目名称:netatmo-swagger-api,代码行数:16,
示例21: JsonObjectJsonObject*SamiCategory::asJsonObject() { JsonObject *pJsonObject = new JsonObject(); pJsonObject->Construct(); JsonString *pIdKey = new JsonString(L"id"); pJsonObject->Add(pIdKey, toJson(getPId(), "Long", "")); JsonString *pNameKey = new JsonString(L"name"); pJsonObject->Add(pNameKey, toJson(getPName(), "String", "")); return pJsonObject;}
开发者ID:0legg,项目名称:swagger-codegen,代码行数:16,
示例22: qobject2qvariantQByteArray NetworkPackage::serialize() const{ //Object -> QVariant //QVariantMap variant; //variant["id"] = mId; //variant["type"] = mType; //variant["body"] = mBody; QVariantMap variant = qobject2qvariant(this); if (hasPayload()) { //qCDebug(KDECONNECT_CORE) << "Serializing payloadTransferInfo"; variant[QStringLiteral("payloadSize")] = payloadSize(); variant[QStringLiteral("payloadTransferInfo")] = mPayloadTransferInfo; } //QVariant -> json auto jsonDocument = QJsonDocument::fromVariant(variant); QByteArray json = jsonDocument.toJson(QJsonDocument::Compact); if (json.isEmpty()) { qCDebug(KDECONNECT_CORE) << "Serialization error:"; } else { /*if (!isEncrypted()) { //qCDebug(KDECONNECT_CORE) << "Serialized package:" << json; }*/ json.append('/n'); } return json;}
开发者ID:KDE,项目名称:kdeconnect-kde,代码行数:29,
示例23: acquireWriteLockQString SimpleJsonDB::jsonString(){ acquireWriteLock(); QString dbString = db->toJson(QMJsonFormat_Pretty, QMJsonSort_CaseSensitive); if (filterVmAndDomstoreKeys) { auto filteredValue = QMJsonValue::fromJson(dbString); if (filteredValue.isNull()) { qCritical("unable to convert db string to qmjsonvalue!"); exit(1); } if (!filteredValue->isObject()) { qCritical("db qmjsonvalue is not an object!"); exit(1); } filteredValue->toObject()->remove("vm"); filteredValue->toObject()->remove("dom-store"); dbString = filteredValue->toJson(QMJsonFormat_Pretty, QMJsonSort_CaseSensitive); } releaseWriteLock(); return dbString;}
开发者ID:cjp256,项目名称:qtdbd,代码行数:29,
示例24: toJsonJson::Value toJson(dev::eth::Transaction const& _t, bytes const& _rlp){ Json::Value res; res["raw"] = toJS(_rlp); res["tx"] = toJson(_t); return res;}
开发者ID:beautifularea,项目名称:aleth,代码行数:7,
示例25: mainint main(){ /* Found three mines in sweep 1 */ int i, no = 10; mine_t c = { -412.55, -929.15 }; mine_t *tmpMines = malloc(sizeof(mine_t)*no); for (i=0; i<no; i++) tmpMines[i] = c; sweep_t *sweep1 = malloc(sizeof(sweep_t)); sweep1->no = no; sweep1->mine_p = tmpMines; /* Convert to Json */ char *jsonString = toJson(sweep1); /* Convert to netstring */ char *netString = toNetString(jsonString); /* Print */ printf("jsonNetString: /"%s/"", netString); free(sweep1); free(tmpMines); free(jsonString); free(netString); return 0;}
开发者ID:ooonak,项目名称:cmess,代码行数:31,
示例26: makeCommandvoid BattleToJson::onSendOut(int spot, int player, ShallowBattlePoke *pokemon, bool silent){ makeCommand("send"); map.insert("slot", player); map.insert("silent", silent); map.insert("pokemon", toJson(*pokemon));}
开发者ID:Amerac,项目名称:pokemon-online,代码行数:7,
示例27: toJson std::string toJson(MessageWraper& obj){ char buffer[1024]; char* p = buffer; *p='{';p++; MessageWraper::CIter iter; MessageWraper::CObjIter objIter; bool begin = true; for(iter = obj.messages.begin();iter!=obj.messages.end();iter++){ if(!begin){ *p++=','; }else{ begin = false; } JSONObjectType type = obj.typeMap[iter->first]; if ((objIter=obj.innerObjects.find(iter->first)) != obj.innerObjects.end()) { addKVPair(p, iter->first.c_str(), toJson(*(objIter->second)).c_str(),true); } else { addKVPair(p, iter->first.c_str(), iter->second.c_str(),type==OBJECT||type==ARRAY); } p++; } *p++='}'; *p='/0'; return std::string(buffer); }
开发者ID:guanliqun,项目名称:ADService,代码行数:25,
注:本文中的toJson函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ toLayerCoordinates函数代码示例 C++ toJS函数代码示例 |