parametersetting.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "parametersetting.h"
  2. #include <QtCore>
  3. ParameterSetting::ParameterSetting(QObject *parent)
  4. : QObject(parent)
  5. {
  6. }
  7. ParameterSetting::~ParameterSetting()
  8. {
  9. }
  10. void ParameterSetting::ParseJson( const QByteArray &arrayjson )
  11. {
  12. QJsonParseError err_rpt;
  13. QJsonDocument root_Doc = QJsonDocument::fromJson(arrayjson, &err_rpt);//字符串格式化为JSON
  14. if(err_rpt.error != QJsonParseError::NoError)
  15. {
  16. qDebug() << "JSON格式错误";
  17. return;
  18. }
  19. else //JSON格式正确
  20. {
  21. QJsonObject object = root_Doc.object();
  22. if (object.contains("decimalCorrection"))
  23. {
  24. m_decimalCorrection = object["decimalCorrection"].toInt(); // 数据类型
  25. }
  26. if (object.contains("commission"))
  27. {
  28. m_commission = object["commission"].toInt(); // 数据类型
  29. }
  30. if (object.contains("saveOrderRecord"))
  31. {
  32. m_bsaveOrderRecord = object["saveOrderRecord"].toBool(); // 数据类型
  33. }
  34. if (object.contains("openPositionPercentage"))
  35. {
  36. m_bopenPositionPercentage = object["saveOrderRecord"].toString(); // 数据类型
  37. }
  38. if (object.contains("closePositionPercentage"))
  39. {
  40. m_bopenPositionPercentage = object["saveOrderRecord"].toString(); // 数据类型
  41. }
  42. if (object.contains("slippage"))
  43. {
  44. m_slippage = object["slippage"].toInt(); // 数据类型
  45. }
  46. if (object.contains("orderMode"))
  47. {
  48. m_orderMode = object["orderMode"].toString(); // 数据类型
  49. }
  50. if (object.contains("orderLevelLimit"))
  51. {
  52. m_orderLevelLimit = object["orderLevelLimit"].toInt(); // 数据类型
  53. }
  54. if (object.contains("orderType"))
  55. {
  56. m_orderType = object["orderType"].toString(); // 数据类型
  57. }
  58. if (object.contains("orderQuantity"))
  59. {
  60. m_orderQuantity = object["orderQuantity"].toInt(); // 数据类型
  61. }
  62. if (object.contains("orderPercentageUp"))
  63. {
  64. m_orderPercentageUp = object["orderPercentageUp"].toInt(); // 数据类型
  65. }
  66. if (object.contains("orderPercentageDown"))
  67. {
  68. m_orderPercentageDown = object["orderPercentageDown"].toInt(); // 数据类型
  69. }
  70. }
  71. }