void CRpcHelper::DupLabel( const address_str& addr, const label_str& label ) { Json::Value args; args.append( addr ); args.append( label ); std::string ret = m_rpc->Send( "setaccount", args ); }
void CRpcHelper::EnterPassword( const std::string& pass ) { Json::Value args; args.append( pass ); args.append( 3 ); std::string ret = m_rpc->Send( "walletpassphrase", args ); }
CRpcHelper::address_str CRpcHelper::NewMulSigAddr( const pubkey_str& PubKey1, const pubkey_str& PubKey2, const pubkey_str& PubKey3 ) { Json::Value keys; keys.append( PubKey1 ); keys.append( PubKey2 ); if( PubKey3.size() ) { keys.append( PubKey3 ); } Json::Value args; args.append( 2 ); args.append( keys ); mini_booklist bakbook = GetMiniBookList(); address_str ret = address_str( m_rpc->Send( "addmultisigaddress", args ) ); label_str old_label = bakbook[ret]; if( old_label.size() ) { args.append( old_label ); std::string ret = m_rpc->Send( "addmultisigaddress", args ); } return ret; }
void KLineProdcut::GetKLineData(const string& startTime, Json::Value& data) { _rwlock.rdlock(); Json::Value js_datalist; Json::Value js_datelist; KlineInfoList::iterator ipos = _klineInfolist.begin(); KlineInfoList::iterator iend = _klineInfolist.end(); for (; ipos != iend; ipos++) { Json::Value object; //开盘价 object.append(ipos->second._open); //收盘价 object.append(ipos->second._close); //最高价 object.append(ipos->second._high); //最低价 object.append(ipos->second._low); js_datalist.append(object); js_datelist.append(QuoteUtils::timeToFmt(ipos->first)); } data["dataList"] = js_datalist; data["dateList"] = js_datelist; _rwlock.unlock(); }
CRpcHelper::txid_str CRpcHelper::SendAmount( const address_str& addr, double fAmount ) { Json::Value args; args.append( addr ); args.append( fAmount ); std::string txid = m_rpc->Send( "sendtoaddress", args ); return txid_str( txid ); }
/** * Returns JSON array from input Vector structure */ Json::Value SkeletonRepresentationJSON::jsonAddPoint3(Eigen::Vector3f point) { Json::Value jsonVector; jsonVector.append(point.x); jsonVector.append(point.y); jsonVector.append(point.z); return jsonVector; }
Json::Value GmResultDigest::asJsonTypeValuePair() const { // TODO(epoger): The current implementation assumes that the // result digest is always of type kJsonKey_Hashtype_Bitmap_64bitMD5 Json::Value jsonTypeValuePair; if (fIsValid) { jsonTypeValuePair.append(Json::Value(kJsonKey_Hashtype_Bitmap_64bitMD5)); jsonTypeValuePair.append(Json::UInt64(fHashDigest)); } else { jsonTypeValuePair.append(Json::Value("INVALID")); } return jsonTypeValuePair; }
Json::Value SpriteRenderer::onSerialize( const std::string& property ) { if( property == "Texture" ) return Json::Value( Assets::use().findTexture( getTexture() ) ); else if( property == "Size" ) { sf::Vector2f s = getSize(); Json::Value v; v.append( Json::Value( s.x ) ); v.append( Json::Value( s.y ) ); return v; } else if( property == "Origin" ) { sf::Vector2f o = getOrigin(); Json::Value v; v.append( Json::Value( o.x ) ); v.append( Json::Value( o.y ) ); return v; } else if( property == "OriginPercent" ) { sf::Vector2f o = getOriginPercent(); Json::Value v; v.append( Json::Value( o.x ) ); v.append( Json::Value( o.y ) ); return v; } else if( property == "Color" ) { sf::Color c = getColor(); Json::Value v; v.append( Json::Value( c.r ) ); v.append( Json::Value( c.g ) ); v.append( Json::Value( c.b ) ); v.append( Json::Value( c.a ) ); return v; } else if( property == "RenderStates" ) { Json::Value v; v[ "blendMode" ] = Serialized::serializeCustom< sf::BlendMode >( "BlendMode", m_renderStates.blendMode ); v[ "shader" ] = Json::Value( Assets::use().findShader( m_renderStates.shader ) ); return v; } else if( property == "Material" ) return m_material.serialize(); else if( property == "MaterialValidation" ) return Json::Value( m_materialValidation ); else return Component::onSerialize( property ); }
//@debug later online void MapModel::writeMapInfo(bool backup){ //const char* route = "parallelSpace.parallelSpaceHandler.notifyRefreshPlayer"; //Json::Value root; //Json::FastWriter writer; //root["uid"] = PlayerManager::getInstance()->getCurPlayer()->getUID(); //CCPomeloWrapper::getInstance()->notify(route, writer.write(root), nullptr); ResourceModel *rm = ResourceModel::getModel(); string filename = mapName + ".info"; if (backup) filename += ".backup"; FILE *fp = rm->OpenFileW(filename); CCASSERT(fp != nullptr, "write map info fail"); const char* route = "parallelSpace.parallelSpaceHandler.writeMapInfo"; Json::Value msg; Json::FastWriter writer; for (auto &building : _buildings){ fprintf(fp, "%d %.0f %.0f %d %s\n", building->getID(), building->getCoord().x, building->getCoord().y, building->getZ(), building->getOwner().c_str()); Json::Value record; record["GID"] = building->getID(); record["coordX"] = (int)building->getCoord().x; record["coordY"] = (int)building->getCoord().y; record["coordZ"] = (int)building->getZ(); record["owner"] = building->getOwner(); record["mapCoord"] = mapName.substr(0, SZ(mapName) - 4); msg.append(record); } if (backup){ for (auto &troop : _troops){ fprintf(fp, "%d %.0f %.0f %d %s\n", troop->getID(), troop->getCoord().x, troop->getCoord().y, troop->getZ(), troop->getOwner().c_str()); Json::Value record; record["GID"] = troop->getID(); record["coordX"] = (int)troop->getCoord().x; record["coordY"] = (int)troop->getCoord().y; record["coordZ"] = (int)troop->getZ(); record["owner"] = troop->getOwner(); record["mapCoord"] = mapName.substr(0, SZ(mapName) - 4); msg.append(record); } } fclose(fp); CCPomeloWrapper::getInstance()->request(route, writer.write(msg), nullptr); }
Json::Value Envelope::toJson() { Json::Value output; output["type"] = "Polygon"; Json::Value nw; nw.append(minVals.latitude); nw.append(minVals.longitude); output["coordinates"].append(nw); Json::Value sw; sw.append(minVals.latitude); sw.append(maxVals.longitude); output["coordinates"].append(sw); Json::Value se; se.append(maxVals.latitude); se.append(maxVals.longitude); output["coordinates"].append(se); Json::Value ne; ne.append(maxVals.latitude); ne.append(minVals.longitude); output["coordinates"].append(ne); output["coordinates"].append(nw); return output; }
Json::Value Bounds::toJson() const { Json::Value json; json.append(m_min.x); json.append(m_min.y); if (is3d()) json.append(m_min.z); json.append(m_max.x); json.append(m_max.y); if (is3d()) json.append(m_max.z); return json; }
bool UserDao::putMatch(User user, User userToMatch){ /**Actualizo los matchs del usuario que invoco la peticion**/ Json::Value root; Json::Value data; vector<string> idUserMatchs = user.getIdUserMatchs(); idUserMatchs.push_back(userToMatch.getId()); for(string id : idUserMatchs){ data.append(id); } user.setIdUserMatchs(idUserMatchs); root["idUserMatchs"] = data; DBtuple keyIdUserMatchs(user.getId() + "_idUserMatchs"); keyIdUserMatchs.value = jsonParser.valueToString(root); bool userMatchOk = this->dataBase->put(keyIdUserMatchs); //Actualizo los matchs del candidato Json::Value rootCandidate; Json::Value dataCandidate; vector<string> idUserToMatchs = userToMatch.getIdUserMatchs(); idUserToMatchs.push_back(user.getId()); for(string id : idUserToMatchs){ dataCandidate.append(id); } rootCandidate["idUserMatchs"] = dataCandidate; DBtuple keyIdUserToMatchs(userToMatch.getId() + "_idUserMatchs"); keyIdUserToMatchs.value = jsonParser.valueToString(rootCandidate); bool userToMatchOk = this->dataBase->put(keyIdUserToMatchs); //Saco el usuario desde el candidato Json::Value rootUserCandidate; Json::Value dataUserCandidate; for(string id : userToMatch.getIdUserCandidatesMatchs()){ id = cleanString(id); if(user.getId().compare(id.c_str()) != 0){ dataUserCandidate.append(id); } } rootUserCandidate["idUserCandidatesMatchs"] = dataUserCandidate; DBtuple keyIdUserCandidateMatchs(userToMatch.getId() + "_idUserCandidatesMatchs"); keyIdUserCandidateMatchs.value = jsonParser.valueToString(rootUserCandidate); bool userToMatchCandidateOk = this->dataBase->put(keyIdUserCandidateMatchs); if(userMatchOk && userToMatchOk && userToMatchCandidateOk){ return true; } return false; }
std::string Socket::json_string() { srand(time(NULL)); int size ; while(1) { size = 50;//rand() % 100 ; if(size > 0) { break ; } } Json::Value root ; Json::Value arr ; while(size) { Json::Value elem ; char title[128] = ""; char summary[128]=""; sprintf(title , "tile_%d", size); sprintf(summary, "summary_%d", size); elem["title"] = title ; elem["summary"] = summary ; arr.append(elem); size -- ; } root["files"]=arr ; Json::FastWriter writer ; Json::StyledWriter stlwriter ; return stlwriter.write(root); }
Json::Value STPath::getJson (int) const { Json::Value ret (Json::arrayValue); for (auto it: mPath) { Json::Value elem (Json::objectValue); int iType = it.getNodeType (); elem[jss::type] = iType; elem[jss::type_hex] = strHex (iType); if (iType & STPathElement::typeAccount) elem[jss::account] = to_string (it.getAccountID ()); if (iType & STPathElement::typeCurrency) elem[jss::currency] = to_string (it.getCurrency ()); if (iType & STPathElement::typeIssuer) elem[jss::issuer] = to_string (it.getIssuerID ()); ret.append (elem); } return ret; }
void ResponseTask::operator()() { Json::Value response; if (getDependencyCount() > _resultTaskIndex) { response = generateResponseJson(); } size_t status = 200; if (!_error_messages.empty()) { Json::Value errors; for (const auto& msg : _error_messages) { errors.append(Json::Value(msg)); } response["error"] = errors; status = 500; } LOG4CXX_DEBUG(_logger, response); Json::FastWriter fw; if (_group_commit) { io::GroupCommitter::getInstance().push( std::tuple<net::AbstractConnection*, size_t, std::string>(connection, status, fw.write(response))); } else { connection->respond(fw.write(response), status); } }
Json::Value MongoDbAdapter::GetSchemaCollection() { mongocxx::instance inst{}; mongocxx::client conn{mongocxx::uri{}}; bsoncxx::stdx::string_view dbName("StorageTestDB"); mongocxx::database database = conn[dbName]; auto cursor = database["schemas"].find({}); Json::Value schemas; Json::Value array; for (auto&& doc : cursor) { string json =bsoncxx::to_json(doc); std::cout << json << std::endl; Json::Value parsedFromString; Json::Reader reader; bool parsingSuccessful = reader.parse(json, parsedFromString); if (parsingSuccessful) { parsedFromString.removeMember("_id"); // Hide the BSON id. array.append(parsedFromString); } } schemas["Schemas"] = array; return schemas; }
void JsonSerializer::recurseRead(Json::Value& jv, any& av) { if(av.type() == typeid(int)) { jv = any_cast<int>(av); } else if(av.type() == typeid(unsigned int)) { jv = any_cast<unsigned int>(av); } else if(av.type() == typeid(long long int)) { jv = any_cast<long long int>(av); } else if(av.type() == typeid(unsigned long long int)) { jv = any_cast<unsigned long long int>(av); } else if(av.type() == typeid(float)) { jv = any_cast<float>(av); } else if(av.type() == typeid(double)) { jv = any_cast<double>(av); } else if(av.type() == typeid(bool)) { jv = any_cast<bool>(av); } else if(av.type() == typeid(string)) { string str = any_cast<string>(av); jv = str; } else if(av.type() == typeid(list<any>)) { auto lst = any_cast<list<any>&>(av); int i = 0; for(auto it:lst) { recurseRead(jv[i], it); ++i; } } else if(av.type() == typeid(list<pair<string, any> >)) { list<pair<string, any> >& lst = any_cast<list<pair<string, any> >&>(av); Json::Value tmp; for(auto it:lst) { recurseRead(tmp[it.first], it.second); } jv.append(tmp); } else { cout<<"error wrong type!"<<endl; } }
bool JsonDataDelegate::add(const StructuredDataName& name, const StructuredData& value) { //TODO Check that value also has a JsonDataDelegate. Cannot mix delegates. StructuredDataDelegate* delegate = getDelegate(const_cast<StructuredData&>(value)); JsonDataDelegate* jsonDelegate = dynamic_cast<JsonDataDelegate *>(delegate); if (name.getPath().empty()) { json_[name.getName()] = jsonDelegate->json_; } else { Json::Value* val = (Json::Value*) getJsonPtr(name, true); if (!val) return false; if (name.getName().empty()) { if (val->isArray()) { Json::Value retval = val->append(jsonDelegate->json_); if (retval.isNull()) { return false; } } else { return false; } } else { (*val)[name.getName()] = jsonDelegate->json_; } } return true; }
void addLine (Json::Value& jsonLines, RippleState const& line) { STAmount const& saBalance (line.getBalance ()); STAmount const& saLimit (line.getLimit ()); STAmount const& saLimitPeer (line.getLimitPeer ()); Json::Value& jPeer (jsonLines.append (Json::objectValue)); jPeer[jss::account] = to_string (line.getAccountIDPeer ()); // Amount reported is positive if current account holds other // account's IOUs. // // Amount reported is negative if other account holds current // account's IOUs. jPeer[jss::balance] = saBalance.getText (); jPeer[jss::currency] = to_string (saBalance.issue ().currency); jPeer[jss::limit] = saLimit.getText (); jPeer[jss::limit_peer] = saLimitPeer.getText (); jPeer[jss::quality_in] = static_cast<Json::UInt> (line.getQualityIn ()); jPeer[jss::quality_out] = static_cast<Json::UInt> (line.getQualityOut ()); if (line.getAuth ()) jPeer[jss::authorized] = true; if (line.getAuthPeer ()) jPeer[jss::peer_authorized] = true; if (line.getNoRipple ()) jPeer[jss::no_ripple] = true; if (line.getNoRipplePeer ()) jPeer[jss::no_ripple_peer] = true; if (line.getFreeze ()) jPeer[jss::freeze] = true; if (line.getFreezePeer ()) jPeer[jss::freeze_peer] = true; }
Json::Value VehicleInfo::vehicleInfoReadDIDResponse(Json::Value &request) { Json::Value did; Json::Value didLocation; didLocation = request["params"]["didLocation"]; did = g_VehicleInfoJson["did"]; int size = int(didLocation.size()); Json::Value arrayObj; Json::Value item; for (int i = 0; i < size; ++i) { item["data"] = did[0]; item["didLocation"] = didLocation[i]; item["resultCode"] = "SUCCESS"; arrayObj.append(item); } Json::Value result; result["code"] = 0; result["method"] = "VehicleInfo.ReadDID"; result["didResult"] = arrayObj; return result; }
Json::Value my::MongoMgr::findJson(const string& col_name) { Json::Value ret = Json::Value::null; string colName = build_db_name(col_name); std::auto_ptr< mongo::DBClientCursor > cursor = m_MongoConn.query(colName); try{ while(cursor->more()) { mongo::BSONObj obj = cursor->next(); if (obj.isEmpty()) { continue; } Json::Reader reader; string tmp = obj.jsonString(); Json::Value p; if (reader.parse(tmp, p)) { ret.append(p); } } }catch(mongo::DBException& e) { printf("%s| caught exception: %s\n", __FUNCTION__, e.what()); } return ret; }
static void ConvertStackToJSON(const ProcessState& aProcessState, const OrderedModulesMap& aOrderedModules, const CallStack *aStack, Json::Value& aNode) { int frameCount = aStack->frames()->size(); unsigned int moduleIndex = 0; for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) { const StackFrame *frame = aStack->frames()->at(frameIndex); Json::Value frameNode; if (frame->module) { auto itr = aOrderedModules.find(frame->module); if (itr != aOrderedModules.end()) { moduleIndex = (*itr).second; frameNode["module_index"] = moduleIndex; } } frameNode["trust"] = FrameTrust(frame->trust); // The 'ip' field is equivalent to socorro's 'offset' field frameNode["ip"] = ToHex(frame->instruction); aNode.append(frameNode); } }
Json::Value CTestjsoncpp::ReleaseJsonValue() { Json::Value jvRoot; jvRoot["result"] = "ok"; //对象元素 Json::Value jvData; Json::Value jvItem1; jvItem1["name"] = "cswuyg_1"; jvItem1["age"] = "2012_1"; jvData.append(jvItem1); //数组元素 Json::Value jvItem2; jvItem2["没意思"] = "呵呵"; jvItem2["age"] = "2012_2"; jvData.append(jvItem2); jvRoot["data"] = jvData; return jvRoot; }
Json::Value formatListOfMapsResponseAsJson(const vector<string> &values, unsigned offset, unsigned values_length, const vector<string> ¶meter_attributes, const vector<string> &default_attributes) { vector<string> attributes = parameter_attributes.size() ? parameter_attributes : default_attributes; if (values_length % attributes.size()) throw SmarttClientException("Invalid number of values received!"); Json::Value response; for (unsigned i = 0; i < values_length / attributes.size(); i++) { Json::Value returnedObject; for (unsigned j = 0; j < attributes.size(); j++) { returnedObject[attributes[j]] = values[offset + i*attributes.size() + j]; } response.append(returnedObject); } return response; }
void ScriptedAutonomous::exportMenus() { ofstream out("/home/lucas/Desktop/menus.json", ofstream::out); Json::Value root; Json::Value menuToExport; Json::Value menus; typedef unordered_multimap<string, ScriptedAutonomous::JsonMenuGroup*>::iterator it; for(it iterator= loadedMenus.begin(); iterator != loadedMenus.end(); iterator++) { JsonMenuGroup *menu = iterator->second; menuToExport["Name"] = menu->name; Json::Value children(Json::arrayValue); for(int ID : *menu->menuGroupIDs) { Json::Value child; child["ID"] = ID; children.append(child); } menuToExport["Children"] = children; menus.append(menuToExport); } root["Menus"] = menus; out << root; out.close(); needsUpdate = true; }
// This is for debugging not end users. Output names can be changed without // warning. Json::Value PathState::getJson () const { Json::Value jvPathState (Json::objectValue); Json::Value jvNodes (Json::arrayValue); for (auto const &pnNode: nodes_) jvNodes.append (pnNode.getJson ()); jvPathState[jss::status] = terStatus; jvPathState[jss::index] = mIndex; jvPathState[jss::nodes] = jvNodes; if (saInReq) jvPathState["in_req"] = saInReq.getJson (0); if (saInAct) jvPathState["in_act"] = saInAct.getJson (0); if (saInPass) jvPathState["in_pass"] = saInPass.getJson (0); if (saOutReq) jvPathState["out_req"] = saOutReq.getJson (0); if (saOutAct) jvPathState["out_act"] = saOutAct.getJson (0); if (saOutPass) jvPathState["out_pass"] = saOutPass.getJson (0); if (uQuality) jvPathState["uQuality"] = boost::lexical_cast<std::string>(uQuality); return jvPathState; }
/// Store and print a log message. void Log(std::string kind, std::string message){ //if last log message equals this one, do not log. if (Storage["log"].size() > 0){ JSON::ArrIter it = Storage["log"].ArrEnd() - 1; if (( *it)[2] == message){ return; } } JSON::Value m; m.append(Util::epoch()); m.append(kind); m.append(message); Storage["log"].append(m); Storage["log"].shrink(100); //limit to 100 log messages std::cout << "[" << kind << "] " << message << std::endl; }
int main() { // global init CRoute4Me::init(); CRoute4Me route(KEY); const char *route_id = "CA902292134DBC134EAF8363426BD247"; ifstream inf("add_order_data.json"); if(!inf.is_open()) { cout << "cannot find a file with addresses" << endl; return -1; } Json::Value body; inf >> body; int ret = route.add_order(body); if (ret == 0) cout << "Order added: " << Json::FastWriter().write(route.get_json_resp()) << endl; else cout << "Error adding order: " << Json::FastWriter().write(route.get_json_resp()) << endl; Json::Value orders; orders.append("1247"); orders.append("1248"); ret = route.remove_order(1, orders); if (ret == 0) cout << "Order removed: " << Json::FastWriter().write(route.get_json_resp()) << endl; else cout << "Error removing order: " << Json::FastWriter().write(route.get_json_resp()) << endl; CRoute4Me::cleanup(); }
int main() { Json::Value fromScratch; Json::Value array; array.append("hello"); array.append("world"); fromScratch["hello"] = "world"; fromScratch["number"] = 2; fromScratch["array"] = array; fromScratch["object"]["hello"] = "world"; output(fromScratch); // write in a nice readible way Json::StyledWriter styledWriter; cout << styledWriter.write(fromScratch); // ---- parse from string ---- // write in a compact way Json::FastWriter fastWriter; std::string jsonMessage = fastWriter.write(fromScratch); Json::Value parsedFromString; Json::Reader reader; bool parsingSuccessful = reader.parse(jsonMessage, parsedFromString); if (parsingSuccessful) { cout << styledWriter.write(parsedFromString) << endl; } cin.ignore(1); return 0; }
/** * Serialize a set of skeletons */ void SkeletonRepresentationSetJSON::Serialize( Json::Value& root ) { root["version"] = this->getVersion(); root["kinectVersion"] = this->getKinectVersion(); root["frameNumber"] = this->getFrameNumber(); root["timeStamp"] = this->getTimeStampdDouble(); // get unix time stamp long seconds, micros; this->getTimeStamp(seconds, micros); root["realTimeStampSeconds"] = seconds; root["realTimeStampMicros"] = micros; root["skeletonCount"] = size(); Json::Value skeletonArray; for (size_t i = 0; i < size(); i++) { skeletonArray.append(this->at(i).Serialize()); } root["skeletons"] = skeletonArray; }