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


C++ StyledWriter::write方法代码示例

本文整理汇总了C++中json::StyledWriter::write方法的典型用法代码示例。如果您正苦于以下问题:C++ StyledWriter::write方法的具体用法?C++ StyledWriter::write怎么用?C++ StyledWriter::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在json::StyledWriter的用法示例。


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

示例1: encode

std::string RechargeRequestData::encode(bool readable)
{
    Json::Value root = encode_to_json_object();
    if ( readable )
    {
        Json::StyledWriter writer;
        return writer.write(root);
    }
    else
    {
        Json::FastWriter writer;
        return writer.write(root);
    }
}
开发者ID:YouLooksLikeNotDelicious,项目名称:websrv,代码行数:14,代码来源:Request.cpp

示例2: encode

 string JobCodec::encode(const Job& job)
 {
     Json::Value root;
     Json::StyledWriter writer;
     
     root["uid"] = job.uid();
     root["data"] = job.data();
     root["status"] = job.status();
     root["status_description"] = job.status_description();
     root["run_at"] = (int)job.run_at();
     root["timestamp"] = (int)job.timestamp();
     
     return writer.write(root);
 }
开发者ID:tomerd,项目名称:q,代码行数:14,代码来源:JobCodec.cpp

示例3: main

int main(int argc, char** argv)
{ 
// ---- create from scratch ----

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;
std::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)
{
    std::cout << styledWriter.write(parsedFromString) << std::endl;
}



  return 0;
}
开发者ID:fayt93,项目名称:Projet,代码行数:37,代码来源:lray.cpp

示例4: _displayMsgToIE

BOOL SessionLayout::_displayMsgToIE(IN MessageEntity msg ,IN CString jsInterface)
{
	module::UserInfoEntity userInfo;
	if (!module::getUserListModule()->getUserInfoBySId(msg.talkerSid, userInfo))
	{
		return FALSE;
	}

	Json::Value root;
	root["name"] = util::cStringToString(userInfo.getRealName());
	root["avatar"] = userInfo.getAvatarPathWithoutOnlineState();
	root["msgtype"] = msg.msgRenderType;
	root["uuid"] = msg.talkerSid;
	CString csContent = util::stringToCString(msg.content);
	ReceiveMsgManage::getInstance()->parseContent(csContent, FALSE, GetWidth(), !msg.isMySendMsg());
	root["content"] = util::cStringToString(csContent);
	if (msg.isMySendMsg())
	{
		root["mtype"] = "me";
	}
	else
	{
		root["mtype"] = "other";
	}
	CTime timeData(msg.msgTime);
	root["time"] = util::cStringToString(timeData.Format(_T("%Y-%m-%d %H:%M:%S")));
	Json::StyledWriter styleWrite;
	std::string record = styleWrite.write(root);
	Json::Reader jsonRead;
	Json::Value rootRead;
	CString jsData = _T("[]");
	if (!jsonRead.parse(record, rootRead) || rootRead.isNull())
	{
		CString csError = util::stringToCString(record, CP_UTF8);
		APP_LOG(LOG_INFO, TRUE, _T("json parse error:%s"), csError);
		jsData = _T("[]");
		return FALSE;
	}
	else
		jsData = util::stringToCString(record, CP_UTF8);
	//调用页面的JS代码
	if (m_pWebBrowser)
	{
		VARIANT VarResult;
		m_pWebBrowser->CallJScript(jsInterface.GetBuffer(), jsData.GetBuffer(), &VarResult);
		jsData.ReleaseBuffer();
	}
	return TRUE;
}
开发者ID:baoruxing,项目名称:TTWinClient,代码行数:49,代码来源:SessionLayout_Function.cpp

示例5: toJSON

/**
 * @brief Serialize to JSON object
 * @return JSON object as std::string
 */
std::string PeakShapeSpherical::toJSON() const {
  Json::Value root;
  PeakShapeBase::buildCommon(root);
  root["radius"] = Json::Value(m_radius);

  if (m_backgroundInnerRadius && m_backgroundOuterRadius) {
    root["background_outer_radius"] =
        Json::Value(m_backgroundOuterRadius.get());
    root["background_inner_radius"] =
        Json::Value(m_backgroundInnerRadius.get());
  }

  Json::StyledWriter writer;
  return writer.write(root);
}
开发者ID:mantidproject,项目名称:mantid,代码行数:19,代码来源:PeakShapeSpherical.cpp

示例6: enviarNivel

void enviarNivel(Socket& sockfd, nivel_t& nivel, string* creador = NULL, int jugadores = 0){
    Json::Value mensaje;
    Json::StyledWriter escritor;

    mensaje["tipo"] = (creador == NULL) ? INFO_CREAR : INFO_UNIRSE;
    mensaje["nombre"] = *(nivel.nombre);
    mensaje["creador"] = (creador == NULL) ? "" : *creador;
    mensaje["puntaje"] = htonl((uint32_t) nivel.puntaje);
    mensaje["max jugadores"] = htonl((uint32_t) nivel.cant_jugadores_max);
    mensaje["jugadores"] = htonl((uint32_t) jugadores);
    std::cout<<mensaje;
    std::string envio = escritor.write(mensaje);

    enviarMsjPrefijo(sockfd, envio.c_str(), envio.length());
}
开发者ID:debmartin,项目名称:log-horizon,代码行数:15,代码来源:SalaPartidas.cpp

示例7: OnIceCandidate

void RtcStream::OnIceCandidate(const webrtc::IceCandidateInterface* candidate) {
    std::string cand;
    if (!candidate->ToString(&cand)) {
        LOG(LS_ERROR) << "Failed to serialize candidate";
        return;
    }

    Json::StyledWriter writer;
    Json::Value jmessage;
    jmessage[kCandidateSdpMidName] = candidate->sdp_mid();
    jmessage[kCandidateSdpMlineIndexName] = candidate->sdp_mline_index();
    jmessage[kCandidateSdpName] = cand;
    std::string encodedCand = talk_base::Base64::Encode( writer.write(jmessage));
    SignalIceCandidate(this, encodedCand);
}
开发者ID:Teaonly,项目名称:_ref_SimpleWebRTC,代码行数:15,代码来源:rtcstream.cpp

示例8:

string  BatchCall::toString     (bool fast) const
{
    string result;
    if (fast)
    {
        Json::FastWriter writer;
        result = writer.write(this->result);
    }
    else
    {
        Json::StyledWriter writer;
        result = writer.write(this->result);
    }
    return result;
}
开发者ID:0328shijian,项目名称:libjson-rpc-cpp,代码行数:15,代码来源:batchcall.cpp

示例9: getFormatted

QString JsonFormatter::getFormatted()
{
	Json::Value root;   
	Json::Reader reader;
	bool parsingSuccessful = reader.parse( rawValue.toStdString(), root );

	if (!parsingSuccessful)
	{
		return QString("Invalid JSON");
	}

	Json::StyledWriter writer;		

	return QString::fromStdString(writer.write(root));
}
开发者ID:BennyH26,项目名称:RedisDesktopManager,代码行数:15,代码来源:JsonFormatter.cpp

示例10: toJSON

std::string MalwrDTO::toJSON(){
    Json::Value root;
    root["md 5"] = md5;
    root["fileName"] = fileName;
    root["fileType"] = fileType;
    root["antivirusScore"] = antivirusScore;
    root["link"] = link;
    root["date"] = date;

    Json::StyledWriter writer;
    std::string outputConfig = writer.write( root );
//    std::cout << outputConfig << std::endl;

    return outputConfig;
}
开发者ID:michto23,项目名称:TKOM,代码行数:15,代码来源:MalwrDTO.cpp

示例11: rewriteValueTree

static int rewriteValueTree(const std::string& rewritePath,
                            const Json::Value& root,
                            std::string& rewrite) {
  // Json::FastWriter writer;
  // writer.enableYAMLCompatibility();
  Json::StyledWriter writer;
  rewrite = writer.write(root);
  FILE* fout = fopen(rewritePath.c_str(), "wt");
  if (!fout) {
    printf("Failed to create rewrite file: %s\n", rewritePath.c_str());
    return 2;
  }
  fprintf(fout, "%s\n", rewrite.c_str());
  fclose(fout);
  return 0;
}
开发者ID:277631272,项目名称:jsoncpp,代码行数:16,代码来源:main.cpp

示例12: constructResponse

std::string MetaRequestHandler::constructResponse() {
  const auto &storageManager = StorageManager::getInstance();
  Json::Value result;
  auto &tables = result["tables"];
  for (const auto & tableName: storageManager->getTableNames()) {
    auto &table = tables[tableName];
    auto &columns = table["columns"];
    auto t = storageManager->getTable(tableName);
    table["columnCount"] = t->columnCount();
    for (field_t i = 0; i != t->columnCount(); i++) {
      columns[t->metadataAt(i)->getName()] = t->metadataAt(i)->getType();
    }
  }
  Json::StyledWriter writer;
  return writer.write(result);
}
开发者ID:InsZVA,项目名称:HyriseVisualizer,代码行数:16,代码来源:MetaRequestHandler.cpp

示例13: JsonCppToString

string JsonTransf::JsonCppToString(Json::Value& jsonValue, const bool bStyled)
{
	string str; 
	if(bStyled)
	{
		Json::StyledWriter writer;
		str = writer.write(jsonValue);
	}
	else
	{
		Json::FastWriter writer;
		str = writer.write(jsonValue);
		str.erase(str.length()-1, 1);
	}
	return str;
}
开发者ID:fengyoung,项目名称:metis,代码行数:16,代码来源:JsonTransf.cpp

示例14: write_user_db

bool write_user_db(Json::Value *root, const std::string &dbpath)
{
    Json::StyledWriter writer;
    std::ofstream userdb_file;
    std::string userdb_json = writer.write(*root);

    userdb_file.open(dbpath,std::ofstream::trunc);
    if (!userdb_file.is_open())
        return false;

    userdb_file << userdb_json;
    userdb_file.close();

    return true;
    
}
开发者ID:hexaclock,项目名称:cs576proj,代码行数:16,代码来源:wolfssl_server.cpp

示例15: saveMap

void MapController::saveMap() {

	Json::Value root;

	std::stringstream ss;
	ss << std::hex << this->map->getSeed();
	root["seed"] = ss.str();

	for (int k = 0; k < turnController->playerList.size(); k++) {
		if (turnController->playerList[k] == turnController->getActivePlayer())
		{
			root["turn"] = k;
		}
	}

	Json::Value countryList;

	for (int i = 0; i < this->map->getNumCountries(); i++)
	{
		Json::Value country;
		for (int k = 0; k < turnController->playerList.size(); k++)
		{
			if (std::find(turnController->playerList[k]->countries.begin(), turnController->playerList[k]->countries.end(), this->map->getCountryById(i)) != turnController->playerList[k]->countries.end())
			{
				country["owner"] = k + 1;
				break;
			}
			else
			{
				country["owner"] = 0;
			}
		}

		country["units"] = this->map->getCountryById(i)->getUnits();
		countryList.append(country);
	}

	root["countries"] = countryList;

    Json::StyledWriter writer;

    std::ofstream myfile;
    myfile.open ("savedConfig.json");
    myfile << writer.write(root);

    myfile.close();
}
开发者ID:noahspriggs,项目名称:seng330,代码行数:47,代码来源:mapcontroller.cpp


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