void Atom::loadJSON(const JSON::Value &value, float scale) { if (0 < value.size()) type = value.getString(0); else THROWS("Atom expected list of at least length 1"); if (String::toUpper(type) == "UNKNOWN") type = "?"; if (1 < value.size()) charge = (float)value.getNumber(1); if (2 < value.size()) radius = (float)value.getNumber(2) * scale; if (3 < value.size()) mass = (float)value.getNumber(3); if (4 < value.size()) number = (unsigned)value.getNumber(4); else number = numberFromName(type); if (!number) number = numberFromName(type); if (!charge) charge = chargeFromNumber(number); if (!radius) radius = radiusFromNumber(number); if (!mass) mass = massFromNumber(number); }
std::vector<Card> parseHandN(json::Value value) { std::vector<Card> hand; for (int i = 0; i < value.size(); ++i) { hand.push_back(Card{value[size_t(i)]}); } std::sort(hand.begin(), hand.end()); return hand; }
void Positions::loadJSON(const JSON::Value &value, float scale) { clear(); for (unsigned i = 0; i < value.size(); i++) { const JSON::List &coord = value.getList(i); if (coord.size() != 3) THROWS("Position expected list of length 3"); push_back(Vector3D(coord.getNumber(0), coord.getNumber(1), coord.getNumber(2)) * scale); } LOG_DEBUG(3, "Read " << size() << " JSON positions"); init(); }
bool UpdateInfoFromServer::parseServerInfo(const Json::Value &serverInfo) { if (serverInfo.isNull()) { return false; } const Json::Value serverSubInfo = serverInfo["server"]; if (serverInfo.isNull()) { return false; } if (m_vecServerInfo.size() > 0) { m_vecServerInfo.clear(); } for (int i=0; i<serverSubInfo.size(); i++) { const Json::Value attributeInfo = serverSubInfo[i]["@attributes"]; if (attributeInfo.isNull()) { m_vecServerInfo.clear(); return false; } else { std::string serverName = attributeInfo["ServerName"].asString(); std::string serverIp = attributeInfo["ServerIP"].asString(); std::string serverPort = attributeInfo["ServerPort"].asString(); ServerInfo oneServerInfo; oneServerInfo.tServerName = serverName; oneServerInfo.tServerIp = serverIp; oneServerInfo.tServerPort = serverPort; m_vecServerInfo.push_back(oneServerInfo); } } return true; }
void CPaperCreateData::LoadData(void) { CJson jc = CJson::Load( "PaperCreate" ); theResDataMgr.insert(this); resource_clear(id_papercreate_map); int32 count = 0; const Json::Value aj = jc["Array"]; for ( uint32 i = 0; i != aj.size(); ++i) { SData *ppapercreate = new SData; ppapercreate->item_id = to_uint(aj[i]["item_id"]); ppapercreate->active_score = to_uint(aj[i]["active_score"]); ppapercreate->level_limit = to_uint(aj[i]["level_limit"]); ppapercreate->skill_type = to_uint(aj[i]["skill_type"]); Add(ppapercreate); ++count; LOG_DEBUG("item_id:%u,active_score:%u,level_limit:%u,skill_type:%u,", ppapercreate->item_id, ppapercreate->active_score, ppapercreate->level_limit, ppapercreate->skill_type); } LOG_INFO("PaperCreate.xls:%d", count); }
std::vector<ServerListSpec> getOnline() { //不要每次都获取 static std::vector<ServerListSpec> serverlist; if (serverlist.size() > 0) { return serverlist; } Json::Value root = fetchJsonValue((g_settings->get("serverlist_url")+"/list").c_str(),0); if (root.isArray()) { for (unsigned int i = 0; i < root.size(); i++) { if (root[i].isObject()) { serverlist.push_back(root[i]); } } } return serverlist; }
void CTombRewardBaseData::LoadData(void) { CJson jc = CJson::Load( "TombRewardBase" ); theResDataMgr.insert(this); resource_clear(id_tombrewardbase_map); int32 count = 0; const Json::Value aj = jc["Array"]; for ( uint32 i = 0; i != aj.size(); ++i) { SData *ptombrewardbase = new SData; ptombrewardbase->id = to_uint(aj[i]["id"]); ptombrewardbase->reward = to_uint(aj[i]["reward"]); ptombrewardbase->tomb_coin = to_uint(aj[i]["tomb_coin"]); ptombrewardbase->desc = to_str(aj[i]["desc"]); Add(ptombrewardbase); ++count; LOG_DEBUG("id:%u,reward:%u,tomb_coin:%u,desc:%s,", ptombrewardbase->id, ptombrewardbase->reward, ptombrewardbase->tomb_coin, ptombrewardbase->desc.c_str()); } LOG_INFO("TombRewardBase.xls:%d", count); }
pAlbumInfo DataManager::apParseArtistAlbums(char *pBuf, unsigned int &size) { Json::Value value; bool ret; size = 0; ret = apParseErrCode((const char*)pBuf, value); if(ret == false) return (pAlbumInfo)NULL; Json::Value works; Json::Value album; unsigned int i; works = value["works"]; album = works["album"]; size = album.size(); pAlbumInfo pAlbum, pHeadAlbum; pHeadAlbum = new AlbumInfo [size]; pAlbum = pHeadAlbum; int len; for(i=0; i < size; i++) { strncpy(pAlbum->album_id, album[i]["id"].asString().c_str(), 34); pAlbum->album_id[35] = '\0'; len = album[i]["name"].asString().size(); //pAlbum->album_title = new char [len +1]; if(len > 127) // ignor the long name len = 127; strncpy(pAlbum->album_title, album[i]["name"].asString().c_str(), len); pAlbum->album_title[len]='\0'; pAlbum++; } return pHeadAlbum; }
BtcTransactions BtcJsonLegacy::ListTransactions(const std::string &account, const int32_t &count, const int32_t &from, const bool &includeWatchonly) { Json::Value params = Json::Value(); params.append(account); params.append(count); params.append(from); Json::Value result = Json::Value(); if(!ProcessRpcString(this->modules->btcRpc->SendRpc(CreateJsonQuery(METHOD_LISTTRANSACTIONS, params)), result)) return BtcTransactions(); // error if(!result.isArray()) return BtcTransactions(); BtcTransactions transactions; for (Json::Value::ArrayIndex i = 0; i < result.size(); i++) { transactions.push_back(BtcTransactionPtr(new BtcTransaction(result[i]))); } return transactions; }
array_2D JSONQuadFeedbackControl::scaleNodeActions (Json::Value actions) { std::size_t numControllers = actions.size(); std::size_t numActions = actions[0].size(); array_2D nodeActions(boost::extents[numControllers][numActions]); array_2D limits(boost::extents[2][numActions]); // Check if we need to update limits assert(numActions == 5); limits[0][0] = m_config.lowFreq; limits[1][0] = m_config.highFreq; limits[0][1] = m_config.lowAmp; limits[1][1] = m_config.highAmp; limits[0][2] = m_config.freqFeedbackMin; limits[1][2] = m_config.freqFeedbackMax; limits[0][3] = m_config.ampFeedbackMin; limits[1][3] = m_config.ampFeedbackMax; limits[0][4] = m_config.phaseFeedbackMin; limits[1][4] = m_config.phaseFeedbackMax; Json::Value::iterator nodeIt = actions.begin(); // This one is square for( std::size_t i = 0; i < numControllers; i++) { Json::Value nodeParam = *nodeIt; for( std::size_t j = 0; j < numActions; j++) { nodeActions[i][j] = ( (nodeParam.get(j, 0.0)).asDouble() * (limits[1][j] - limits[0][j])) + limits[0][j]; } nodeIt++; } return nodeActions; }
drag_plane_vector parse_drag_planes(const Json::Value& arr) { if (!arr.isArray()) { throw std::runtime_error("Expected array of drag planes."); } drag_plane_vector dps; for (unsigned int i = 0; i < arr.size(); i++) { Json::Value root = arr[i]; if (!root.isObject()) { throw std::runtime_error("Expected drag plane object."); } PARSE_VECTOR3(pos); PARSE_VECTOR3(normal); PARSE_DOUBLE(cD); PARSE_DOUBLE(area); drag_plane dp { pos, normal, cD, area }; dps.push_back(dp); } return dps; }
// // Parse the infile, which is either an ascii list of GTC files, or a JSON format file // Return an array of filenames and (for a JSON file) a list of sample names // void parseInfile(string infile, vector<string> &sampleNames, vector<string> &infiles) { Json::Value root; // will contains the root value after parsing. Json::Reader reader; ifstream f; f.open(infile.c_str()); if (infile.find(".json") != string::npos) { // Parse JSON file bool parsingSuccessful = reader.parse( f, root ); if ( !parsingSuccessful ) throw("Could not parse json file "+infile); for ( unsigned int index = 0; index < root.size(); ++index ) { sampleNames.push_back(root[index]["uri"].asString()); infiles.push_back(root[index]["result"].asString()); } } else { // simple ascii text file string filename; while (f >> filename) infiles.push_back(filename); } f.close(); }
CString CConnectionManager::GetStory(Json::Value& msg) { int changed = 0; int created = 0; int deleted = 0; int renamed = 0; Json::Value files = msg["files"]; for (unsigned int i=0; i<files.size(); i++) { Json::Value file = files[i]; CString action = UnpackValue(file["action"]); if (action==_T("changed")) changed++; if (action==_T("created")) created++; if (action==_T("deleted")) deleted++; if (action==_T("renamed")) renamed++; } CString fs; CString s[4]; int i = 0; fs = FileSentence(created, _T("created")); if (fs.GetLength()) s[i++] = fs; fs = FileSentence(deleted, _T("deleted")); if (fs.GetLength()) s[i++] = fs; fs = FileSentence(changed, _T("changed")); if (fs.GetLength()) s[i++] = fs; fs = FileSentence(renamed, _T("renamed")); if (fs.GetLength()) s[i++] = fs; CString story; if (i==0) return _T("?"); if (i==1) story.Format(_T("%s"), s[0]); if (i==2) story.Format(_T("%s and %s"), s[0], s[1]); if (i==3) story.Format(_T("%s, %s and %s"), s[0], s[1], s[2]); if (i==4) story.Format(_T("%s, %s, %s and %s"), s[0], s[1], s[2], s[3], s[4]); return story; }
void CTransactionRecordsResultMsg::ParseJSon(const char* json) { USES_CONVERSION; Json::Reader reader; Json::Value root; if (reader.parse(json, root)) { Error = root["errcode"].asInt(); ErrMsg = A2T(root["errmsg"].asString().c_str()); Json::Value data = root["data"]; InitBP = data["init_bp"].asDouble(); BP = data["bp"].asDouble(); ClosePL = data["close_pl"].asDouble(); TradeFee = data["trade_fee"].asDouble(); Json::Value stocks = data["stocks"]; for (UINT i = 0; i < stocks.size(); i++) { Json::Value ¤t = stocks[i]; CStokes* SStokes = new CStokes; Stokes.push_back(SStokes); SStokes->StockID = A2T(current["stock_id"].asString().c_str()); SStokes->BuyVol = current["buy_vol"].asInt(); SStokes->BuyAmount = current["buy_amount"].asDouble(); SStokes->BuyPrice = current["buy_price"].asDouble(); SStokes->SellVol = current["sell_vol"].asInt(); SStokes->SellAmount = current["sell_amount"].asDouble(); SStokes->SellPrice = current["sell_price"].asDouble(); SStokes->ClosePL = current["close_pl"].asDouble(); SStokes->TradeFee = current["trade_fee"].asDouble(); } } }
// // parse_device // Get the devices that described in a root of json file // int parse_device(Json::Value &value) { switch (value.type()) { case Json::nullValue: break; case Json::arrayValue: { // Travel the elements in array int size = value.size(); for (int index = 0; index < size; ++index) parse_device(value[index]); } break; case Json::objectValue: { // Create device instance according device type if (value[DEVICE_NAME] == Json::nullValue) dbg_print("WARNING: Should to specify the name for device\n"); // Should specify a device type in json elements if (value[DEVICE_TYPE] == Json::nullValue) { printf("ERROR: Need to specify the device type for device\n"); break; } dbg_print("INFO: Got device [%s]\n", value[DEVICE_NAME].asString().c_str()); // Create device instance according device type if (create_device_map[value[DEVICE_TYPE].asString()] != NULL) (*create_device_map[value[DEVICE_TYPE].asString()])(value); else dbg_print("INFO: Not the function to create a %s instance\n", value[DEVICE_TYPE].asString().data()); } break; default: break; } return 0; }
bool Game::update_game(std::string message) { Json::Value root; Json::Reader reader; reader.parse(message,root,false); if(root["type"].asString() != "changes") { return false; } Json::Value changes = root["args"]["changes"]; std::stringstream convert; for(int i = 0; i < changes.size(); i++) { convert<<changes[i]; if(changes[i]["action"].asString() == "add") { change_add(convert.str()); } else if(changes[i]["action"].asString() == "remove") { change_remove(convert.str()); } else if(changes[i]["action"].asString() == "update") { change_update(convert.str()); } else if(changes[i]["action"].asString() == "global_update") { change_global_update(convert.str()); } convert.str(std::string()); } return true; }
bool jsonParser::checkSpecEssentials(Json::Value &child, std::map<std::string, PLASMA*> plasmas){ bool isEnambled = false; bool isThereName = false; bool isThereType = false; bool isTherePlasma = false; bool isTherePPC = false; std::string dummy; if (inputVersion == 1) isEnambled = true; setBool(&isEnambled, child, _JSON_BOOL_ENABLED); isThereName = setString(&dummy, child, _JSON_STRING_SPECIE_NAME); if (setString(&dummy, child, _JSON_STRING_SPECIE_PLASMANAME)){ if (plasmas.find(dummy) != plasmas.end()) isTherePlasma = true; } Json::Value ppc; if (setValue(ppc, child, _JSON_INTARRAY3_PARTICLES_PER_CELL)){ if (ppc.isArray() && (ppc.size() == 3)) if (ppc[0].asInt() >= 0 && ppc[1].asInt() >= 0 && ppc[2].asInt() >= 0) isTherePPC = true; } if (setString(&dummy, child, _JSON_STRING_SPECIES_TYPE)){ if (dummy.compare(SPECIES_TYPEVALUE_ELECTRON) || dummy.compare(SPECIES_TYPEVALUE_POSITRON) || dummy.compare(SPECIES_TYPEVALUE_ION)) isThereType = true; } return isEnambled&&isThereName&&isThereType&&isTherePlasma&&isTherePPC; }
Result FriendsAPI::getAppFriends(const string &sessionKey, QVector<UserInfo> &list) { RequestParam params; params.addParam("api_key", Config::m_apiKey); params.addParam("method", Method::FRIENDS_GET_APP_FRIENDS); params.addParam("call_id", Utility::getCallId()); params.addParam("v", Config::m_apiVersion); params.addParam("session_key", sessionKey); params.addParam("format", Config::m_resultFormat); params.addParam("fields", Config::m_appFriendsFields); params.addParam("sig", Utility::stringToUTF8(Utility::getSignature(params))); Response response; m_request->syncRequest(Config::m_RESTServerURL, Request::Post, params, &response); Json::Value root; Json::Reader reader; if(reader.parse(response.getRawData(), root, false)) { if(!root.isArray() && !root["error_code"].isNull()) return root["error_code"].asUInt(); for(unsigned int i = 0; i < root.size(); i++) { Json::Value singleUserInfo = root[i]; UserInfo userInfo; userInfo.m_uid = singleUserInfo["uid"].asUInt(); userInfo.m_name = singleUserInfo["name"].asString(); userInfo.m_headURL = singleUserInfo["headurl"].asString(); userInfo.m_tinyURL = singleUserInfo["tinyurl"].asString(); list.push_back(userInfo); } return RESULT_OK; } else return RESULT_JSON_INVALID; }
bool CClientApp::LoadParams(const char* path) { m_Params.clear(); Zion::String strXmlFile = path?path:Zion::GetHomeDirectory(); if(path) { strXmlFile = Zion::StringFormat("%s%s", path, "Client.json"); } else { strXmlFile += "\\Config\\Client.json"; } std::ifstream ifs; ifs.open(strXmlFile.c_str()); if(!ifs.is_open()) return false; Json::Reader reader; Json::Value root; if (!reader.parse(ifs, root, false)) { return false; } for(Json::UInt i = 0; i < root.size(); ++i) { Zion::Array<Zion::String> vec = root.getMemberNames(); Zion::String strKey = vec[i]; Zion::String strValue = root[strKey.c_str()].asString(); m_Params[strKey] = strValue; } ifs.close(); return true; }
bool SiteClient::login(HTTPD::SiteSession *session, std::string username, std::string password) { Json::Value body; body["username"] = username; body["password"] = password; Json::StyledWriter writer; std::string output = writer.write(body); int res; std::string replyBuffer; res = postJSON(session, "user/login", output, replyBuffer); if(res == 200) { Json::Value root; Json::Reader reader; if (reader.parse( replyBuffer.c_str(), root ) && root.size() > 0) { session->sessionID = root["sessid"].asCString(); session->sessionName = root["session_name"].asCString(); return true; } } else { g_Logs.server->warn("Failed to authenticate with error %v", res); } return false; }
void CSoldierStarData::LoadData(void) { CJson jc = CJson::Load( "SoldierStar" ); theResDataMgr.insert(this); resource_clear(id_soldierstar_map); int32 count = 0; const Json::Value aj = jc["Array"]; for ( uint32 i = 0; i != aj.size(); ++i) { SData *psoldierstar = new SData; psoldierstar->lv = to_uint(aj[i]["lv"]); psoldierstar->cost = to_uint(aj[i]["cost"]); std::string need_money_string = aj[i]["need_money"].asString(); sscanf( need_money_string.c_str(), "%u%%%u%%%u", &psoldierstar->need_money.cate, &psoldierstar->need_money.objid, &psoldierstar->need_money.val ); psoldierstar->grow = to_uint(aj[i]["grow"]); Add(psoldierstar); ++count; LOG_DEBUG("lv:%u,cost:%u,grow:%u,", psoldierstar->lv, psoldierstar->cost, psoldierstar->grow); } LOG_INFO("SoldierStar.xls:%d", count); }
int DataManager::ParseRndInfo( struct MemoryStruct *pJson) { Json::Reader reader; Json::Value value; bool ret; ret = reader.parse((const char*)pJson->memory, value); if (!ret) { // report to the user the failure and their locations in the document. std::cout << "Failed to parse configuration\n"<< reader.getFormatedErrorMessages(); return false; } if (value["status"].isNull()) { printf("get songs null\n"); return 0; } Json::Value songs = value["songs"]; SongInfo *pSongs = SongRndList; pSongs->size = songs.size(); return parse_songs(songs, pSongs, XIAMI_MAX_RND_NUM); }
int CUSERCommand::doWhat(CClient *pClient) { if(!m_Args.empty()){ Json::Value value; Json::Reader reader; if(reader.parse(CCommand::GetUserInfo(),value)){ Json::Value user = value["user"]; for(int i = 0;i < user.size();i++){ string name = user[i]["name"].asString(); if(name == m_Args){ pClient->SetClientName(name); } } } else{ cout << "Load user info error,now exit." << endl; exit(-1); } } string ret = "331 Please specify the password.\r\n"; pClient->sendMsg(ret); pClient->SetClientState(USER); return 1; }
void NPCInfoCfg::FillBuildingData(const Json::Value& jsBld,vector<BuildingItemJson> &ItemJson) { if(jsBld.isArray()) { int nCnt = jsBld.size(); for(int i=0; i<nCnt; i++) { BuildingItemJson bij; const Json::Value& subData = jsBld[i]; bij.sid = subData[(UINT)0].asInt(); bij.skuId = subData[(UINT)1].asInt(); bij.id = subData[(UINT)2].asInt(); bij.upgradeId = subData[(UINT)3].asInt(); bij.type = subData[(UINT)4].asInt(); bij.state = subData[(UINT)5].asInt(); bij.x = subData[(UINT)6].asInt(); bij.y = subData[(UINT)7].asInt(); bij.energy = subData[(UINT)8].asInt(); bij.energyPercent = subData[(UINT)9].asInt(); ItemJson.push_back(bij); } } }
void TemplateParameters::read(const string& parFile) /*****************************************************************/ { Json::Value root; Json::Reader reader; std::ifstream pars(parFile, std::ifstream::binary); if(!pars.is_open()) { stringstream error; error << "TemplateParameters::read(): Cannot open parameter file '"<<parFile<<"'\n"; throw runtime_error(error.str()); } bool parsingSuccessful = reader.parse( pars, root ); if(!parsingSuccessful) { stringstream error; error << "TemplateParameters::read(): Problem while reading parameter file. Parser error follows. \n"<<reader.getFormatedErrorMessages()<<"\n"; throw runtime_error(error.str()); } m_inputDirectory = root.get("inputDirectory", "./" ).asString(); m_outputFileName = root.get("outputFile", "templates.root" ).asString(); const Json::Value templates = root["templates"]; if(templates.isNull()) { stringstream error; error << "TemplateParameters::read(): No template defined"; throw runtime_error(error.str()); } for(unsigned int index = 0; index < templates.size(); ++index) { readTemplate(templates[index]); } pars.close(); }
Cold::Cold( arbiter::Endpoint& endpoint, const Builder& builder, const std::size_t clipPoolSize, const Json::Value& jsonIds) : m_endpoint(endpoint) , m_builder(builder) , m_chunkVec(getNumFastTrackers(builder.structure())) , m_chunkMap() , m_mapMutex() , m_pool(new Pool(clipPoolSize, clipQueueSize)) { if (jsonIds.isArray()) { Id id(0); const Structure& structure(m_builder.structure()); for (std::size_t i(0); i < jsonIds.size(); ++i) { id = Id(jsonIds[static_cast<Json::ArrayIndex>(i)].asString()); const ChunkInfo chunkInfo(structure.getInfo(id)); const std::size_t chunkNum(chunkInfo.chunkNum()); if (chunkNum < m_chunkVec.size()) { m_chunkVec[chunkNum].mark.store(true); } else { std::unique_ptr<CountedChunk> c(new CountedChunk()); m_chunkMap.emplace(id, std::move(c)); } } } }
bool Monster::init(int ID) { this->m_ID = ID; /* ----------- 读取怪物配置文件 ------------ */ /* 读取配置文件字符串数据 */ std::string sData = FileUtils::getInstance()->getStringFromFile("monsterConf.plist"); /* 用于解析Json */ Json::Reader reader; /* 解析Json后的根节点 */ Json::Value root; /* 开始解析 */ if (!reader.parse(sData, root, false)) { return false; } /* 在这里,根节点是一个数组,遍历数组,找到我们要的ID */ int size = root.size(); for (int i = 0; i < size; ++i) { int id = root[i]["id"].asInt(); if (id == ID) { m_sModelPath = root[i]["model"].asCString(); m_iAtk = root[i]["atk"].asInt(); break; } } return true; }
void COrderInquiryResultMsg::ParseJSon(const char* json) { USES_CONVERSION; Json::Reader reader; Json::Value root; if (reader.parse(json, root)) // reader将Json字符串解析到root,root将包含Json里所有子元素 { Error = root["errcode"].asInt(); ErrMsg = A2T(root["errmsg"].asString().c_str()); Json::Value data = root["data"]; Json::Value orders = data["orders"]; for (UINT i = 0; i < orders.size(); i++) { Json::Value ¤t = orders[i]; COrders* Sorder = new COrders(); Orders.push_back(Sorder); Sorder->Done = current["done"].asInt(); Sorder->OrderRef = current["order_ref"].asInt(); Sorder->OrderID = A2T(current["order_id"].asString().c_str()); Sorder->ReportTime = current["report_time"].asInt(); Sorder->OrderType = A2T(current["order_type"].asString().c_str()); Sorder->StockID = A2T(current["stock_id"].asString().c_str()); Sorder->Volume = current["volume"].asInt(); Sorder->Price = current["price"].asDouble(); Sorder->ExeVol = current["exe_vol"].asInt(); Sorder->ExeAmount = current["exe_amount"].asDouble(); Sorder->ExePrice = current["exe_price"].asDouble(); Sorder->Status = current["status"].asInt(); Sorder->Error = current["error"].asInt(); Sorder->ErrMsg = A2T(current["errmsg"].asString().c_str()); } } }
bool ItemManager::Read(const char* filename) { // 读取数据 Json::Reader reader; Json::Value root; ifstream is; is.open(filename, ios::binary); if (reader.parse(is, root)) { int iSize = root.size(); for (int i = 0; i < iSize; i++) { string id = root[i]["id"].asString(); string name = root[i]["name"].asString(); float price = root[i]["price"].asFloat(); string type = root[i]["type"].asString(); map<string, Item*>::iterator it = m_mapItems.find(id); if (it != m_mapItems.end()) { printf("该ID商品已存在,取消录入\n"); continue; } Item* pItem = new Item(); pItem->strId = id; pItem->strName = name; pItem->strType = type; pItem->fPrice = price; m_mapItems[id] = pItem; } } return true; }
bool CThermosmart::GetOutsideTemperatureFromDomoticz(float &tvalue) { if (m_OutsideTemperatureIdx == 0) return false; Json::Value tempjson; std::stringstream sstr; sstr << m_OutsideTemperatureIdx; m_webservers.GetJSonDevices(tempjson, "", "temp", "ID", sstr.str(), "", "", true, false, false, 0, ""); size_t tsize = tempjson.size(); if (tsize < 1) return false; Json::Value::const_iterator itt; Json::ArrayIndex rsize = tempjson["result"].size(); if (rsize < 1) return false; bool bHaveTimeout = tempjson["result"][0]["HaveTimeout"].asBool(); if (bHaveTimeout) return false; tvalue = tempjson["result"][0]["Temp"].asFloat(); return true; }