[
{
"s": {
"id": 3,
"b": 1,
"s": 1,
"o": 0,
"name": "布林线",
"desc": "56CW5b2i5Zu+54Sm54KtMTB0aWNr44CBMjB0aWNrIDQwdGljayDluIPmnpfnur/nrZbnlaU=",
"level": {
"1": "5 tick",
"2": "10 tick",
"3": "20 tick",
"4": "40 tick",
"5": "50 tick"
}
}
}
]
QJsonParseError e;
Account* accout;
QJsonDocument document = QJsonDocument::fromJson(m_unzip_buffer.c_str(), &e);
if(e.error == QJsonParseError::NoError && !document.isNull()){
if(document.isArray()){
QJsonArray array = document.array();
accout = g_stockData.current_account;
if(accout->strategys.size()>0)
accout->strategys.clear();//清理
for(int index = 0;index<array.size();index++){
QJsonObject value = array.at(index).toObject().value("s").toObject();
StrategyItemInfo strategy_item;
strategy_item.userInfo.strategy_id = value.value("id").toInt();
strategy_item.userInfo.buy = value.value("b").toInt();
strategy_item.userInfo.sell = value.value("s").toInt();
strategy_item.userInfo.name = value.value("name").toString();
strategy_item.userInfo.desc = QString(QByteArray::fromBase64(value.value("desc").toString().toLatin1()));//base64解码
QJsonObject level = value.value("level").toObject();
QStringList keys = level.keys();
for(QString l:keys){
strategy_item.userInfo.level.insert(l,level.value(l).toString());
}
}
}
}