詳細:
この github プロジェクトを使用して、Json をオブジェクトに変換しています。
https://github.com/ereilin/qt-json
このjsonで:
{
"bin": "/home/pablo/milaoserver/compile/Devices01.olk",
"temp":"/home/pablo/milaoserver/temporal/",
"port": "1234",
"name": "lekta",
}
この 2 行で、2 つの char ポインターを作成します。
char* bin = configuration["bin"].toString().toLatin1().data();
char* temp = configuration["temp"].toString().toLatin1().data();
アプリのデバッグ 適切な文字列があります。
ただし、それらを使用すると、具体的には「bin」文字が次のように変わります
`hom
何か案が?
コメントの解決策:
問題はデータの「永続性」でした。
私は解決策を見つけました:
std::string binAux(configuration["bin"].toString().toLatin1().data());
std::string tempAux(configuration["temp"].toString().toLatin1().data());
char* bin = new char[binAux.size()+1] ;
strcpy(bin, binAux.c_str());
char* temp = new char[tempAux.size()+1] ;
strcpy(temp, tempAux.c_str());