boost中property_tree操作内存中的数据

void ReadJson(const char * szJson)
{
	std::stringstream ss(szJson);
	boost::property_tree::ptree pt;
	boost::property_tree::read_json(ss, pt);
	
	// 读取数据
	// pt.get<int>("cmd");
	
	return;
}

void WriteJson()
{
	boost::property_tree::ptree pt;
	
	// 写入数据
	// ...
	
	std::stringstream ss;
	write_json(ss, pt);
	std::string strJson = ss.str();

	cout << strJson << endl;
}
上面是以json为例,xml和ini应该类似?

你可能感兴趣的:(boost中property_tree操作内存中的数据)