我有一个std::string configFile;
std::string ReadINI_String(const std::string &sSection, const std::string &sSub, const std::string &sDefaultValue)
{
char sResult[256] = {};
GetPrivateProfileString( sSection.c_str(), sSub.c_str(), sDefaultValue.c_str(), sResult, 255, configFile.c_str() );
return sResult;
}
int ReadINI_Int(const std::string &sSection, const std::string &sSub, int iDefaultValue)
{
return GetPrivateProfileInt( sSection.c_str(), sSub.c_str(), iDefaultValue, configFile.c_str() );
}
...
char path[MAX_PATH] = {};
GetModuleFileNameA(NULL, path, MAX_PATH);
PathRemoveFileSpecA(path);
PathCombineA(path, path, "config.ini");
configFile = path;
...
int i_width = ReadINI_Int("CONFIGURATION", "WIN_WIDTH", 0);
int i_height = ReadINI_Int("CONFIGURATION", "WIN_HEIGHT", 0);
std::string s_value = ReadINI_String("CONFIGURATION", "WIN_NAME", "null");
std::cout << "Width: " << i_width << "\n";
std::cout << "Height: " << i_height << "\n";
std::cout << "Name: " << s_value << "\n";
对象,例如
json
我想将其转换为{"f1": 2.1, "f2": 3.2, "f3": 1234.12, "label": "GOOD"}
实例
答案 0 :(得分:0)
要在Java中执行此操作,将需要解析JSON并构造Mallet实例。我发现Java JSON解析很困难,因为该语言希望每个对象都有类型。
我个人建议使用python脚本或类似工具将JSON文件转换为Mallet接受的“ svmlight”格式。