|  | @@ -1,90 +0,0 @@
 | 
	
		
			
				|  |  | -#include "vtkjsonobject.h"
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -vtkJsonObject::vtkJsonObject()
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -/*
 | 
	
		
			
				|  |  | - * @brief: parsing json msg
 | 
	
		
			
				|  |  | - * @param: json msg
 | 
	
		
			
				|  |  | - * @brief: void
 | 
	
		
			
				|  |  | - * @birth: created by czm in 20230404
 | 
	
		
			
				|  |  | - */
 | 
	
		
			
				|  |  | -void vtkJsonObject::FromJSON(std::string msg)
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -    QByteArray byteArray(msg.c_str(),msg.length());
 | 
	
		
			
				|  |  | -    QJsonParseError jsonError;
 | 
	
		
			
				|  |  | -    QJsonDocument doucment = QJsonDocument::fromJson(byteArray, &jsonError);  // 转化为 JSON 文档
 | 
	
		
			
				|  |  | -    if (!doucment.isNull() && (jsonError.error == QJsonParseError::NoError)) {  // 解析未发生错误
 | 
	
		
			
				|  |  | -        if (doucment.isObject()) {  // JSON 文档为对象
 | 
	
		
			
				|  |  | -            QJsonObject object = doucment.object();  // 转化为对象
 | 
	
		
			
				|  |  | -            if (object.contains("usrId")) {
 | 
	
		
			
				|  |  | -                QJsonValue value = object.value("usrId");
 | 
	
		
			
				|  |  | -                if (value.isString()) {
 | 
	
		
			
				|  |  | -                    this->usrId = value.toString();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (object.contains("solverConfigid")) {
 | 
	
		
			
				|  |  | -                QJsonValue value = object.value("solverConfigid");
 | 
	
		
			
				|  |  | -                if (value.isString()) {
 | 
	
		
			
				|  |  | -                    this->solverConfigid = value.toString();;
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (object.contains("proId")) {
 | 
	
		
			
				|  |  | -                QJsonValue value = object.value("proId");
 | 
	
		
			
				|  |  | -                if (value.isString()) {
 | 
	
		
			
				|  |  | -                    this->proId = value.toString();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (object.contains("paramJson")) {
 | 
	
		
			
				|  |  | -                QJsonValue value = object.value("paramJson");
 | 
	
		
			
				|  |  | -                if (value.isString()) {
 | 
	
		
			
				|  |  | -                   this->paramJson = value.toString();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (object.contains("action")) {
 | 
	
		
			
				|  |  | -                QJsonValue value = object.value("action");
 | 
	
		
			
				|  |  | -                if (value.isString()) {
 | 
	
		
			
				|  |  | -                   this->action = value.toString();
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -vtkJsonObject *vtkJsonObject::operator=(vtkJsonObject *object)
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -    this->usrId = object->usrId;
 | 
	
		
			
				|  |  | -    this->solverConfigid = object->solverConfigid;
 | 
	
		
			
				|  |  | -    this->proId = object->proId;
 | 
	
		
			
				|  |  | -    this->paramJson = object->paramJson;
 | 
	
		
			
				|  |  | -    this->action = object->action;
 | 
	
		
			
				|  |  | -    return this;
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -/*
 | 
	
		
			
				|  |  | - * @brief: Build JSON message
 | 
	
		
			
				|  |  | - * @param: img file
 | 
	
		
			
				|  |  | - * @brief: josn msg
 | 
	
		
			
				|  |  | - * @birth: created by czm in 20230404
 | 
	
		
			
				|  |  | - */
 | 
	
		
			
				|  |  | -std::string vtkJsonObject::ToJson(std::string imgfile)
 | 
	
		
			
				|  |  | -{
 | 
	
		
			
				|  |  | -    QJsonObject json;
 | 
	
		
			
				|  |  | -    json.insert("usrId",this->usrId);
 | 
	
		
			
				|  |  | -    json.insert("solverConfigid",this->solverConfigid);
 | 
	
		
			
				|  |  | -    json.insert("proId",this->proId);
 | 
	
		
			
				|  |  | -    json.insert("paramJson",this->paramJson);
 | 
	
		
			
				|  |  | -    json.insert("action",this->action);
 | 
	
		
			
				|  |  | -    json.insert("img",QString::fromStdString(imgfile));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    QJsonDocument document;
 | 
	
		
			
				|  |  | -    document.setObject(json);
 | 
	
		
			
				|  |  | -    QByteArray byteArray = document.toJson(QJsonDocument::Compact);
 | 
	
		
			
				|  |  | -    QString strJson(byteArray);
 | 
	
		
			
				|  |  | -    return strJson.toStdString();
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | -
 |