#include "stdafx.h" #include "CVersion.h" CVersion::CVersion() { } CVersion::~CVersion() { } bool CVersion::Inti(std::string data) { if (data.empty()) { return false; } try { nlohmann::json j = nlohmann::json::parse(data.begin(), data.end()); if (j["ret"].get() == 1) { // this->appversion = j["data"]["appversion"].get(); this->appdownload = j["data"]["appdownload"].get(); this->appmsg = j["data"]["appmsg"].get(); return true; } else { SStringW msg; msg.Format(L"当前版本号:%s", VERSION, S_CA2W(j["msg"].get().c_str(), CP_UTF8)); this->m_error_msg = msg.GetBuffer(0); return false; } } catch (...) { this->m_error_msg = L"解析数据错误"; return false; } return false; }