| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "parametersetting.h"
- #include <QtCore>
- ParameterSetting::ParameterSetting(QObject *parent)
- : QObject(parent)
- {
- }
- ParameterSetting::~ParameterSetting()
- {
- }
- void ParameterSetting::ParseJson( const QByteArray &arrayjson )
- {
- QJsonParseError err_rpt;
- QJsonDocument root_Doc = QJsonDocument::fromJson(arrayjson, &err_rpt);//字符串格式化为JSON
- if(err_rpt.error != QJsonParseError::NoError)
- {
- qDebug() << "JSON格式错误";
- return;
- }
- else //JSON格式正确
- {
- QJsonObject object = root_Doc.object();
- if (object.contains("decimalCorrection"))
- {
- m_decimalCorrection = object["decimalCorrection"].toInt(); // 数据类型
- }
- if (object.contains("commission"))
- {
- m_commission = object["commission"].toInt(); // 数据类型
- }
- if (object.contains("saveOrderRecord"))
- {
- m_bsaveOrderRecord = object["saveOrderRecord"].toBool(); // 数据类型
- }
- if (object.contains("openPositionPercentage"))
- {
- m_bopenPositionPercentage = object["saveOrderRecord"].toString(); // 数据类型
- }
- if (object.contains("closePositionPercentage"))
- {
- m_bopenPositionPercentage = object["saveOrderRecord"].toString(); // 数据类型
- }
- if (object.contains("slippage"))
- {
- m_slippage = object["slippage"].toInt(); // 数据类型
- }
- if (object.contains("orderMode"))
- {
- m_orderMode = object["orderMode"].toString(); // 数据类型
- }
- if (object.contains("orderLevelLimit"))
- {
- m_orderLevelLimit = object["orderLevelLimit"].toInt(); // 数据类型
- }
- if (object.contains("orderType"))
- {
- m_orderType = object["orderType"].toString(); // 数据类型
- }
- if (object.contains("orderQuantity"))
- {
- m_orderQuantity = object["orderQuantity"].toInt(); // 数据类型
- }
- if (object.contains("orderPercentageUp"))
- {
- m_orderPercentageUp = object["orderPercentageUp"].toInt(); // 数据类型
- }
- if (object.contains("orderPercentageDown"))
- {
- m_orderPercentageDown = object["orderPercentageDown"].toInt(); // 数据类型
- }
- }
- }
|