12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #pragma once
- #include <iostream>
- #include <rapidjson/document.h>
- #include <rapidjson/rapidjson.h>
- #include <rapidjson/stringbuffer.h>
- #include <rapidjson/writer.h>
- using namespace std;
- class HepuLoginRe
- {
- private:
- public:
- const string cmd = "userLogin";
- int ackvalue;
- string token;
- HepuLoginRe(){};
- ~HepuLoginRe(){};
- bool jsonToObject(string& json){
- rapidjson::Document doc;
- doc.Parse(json.c_str());
- if(!doc.IsObject()){
- return false;
- }
- const auto end = doc.MemberEnd();
- if(end == doc.FindMember("cmd") || !doc["cmd"].IsString()){
- return false;
- }else{
- if(cmd != doc["cmd"].GetString())
- return false;
- }
- if(end == doc.FindMember("param") || !doc["param"].IsObject()) {
- return false;
- }else{
- if(end == doc.FindMember("ackvalue") || !doc["ackvalue"].IsInt()) {
- return false;
- }else{
- ackvalue = doc["token"].GetInt();
- }
- if(end == doc.FindMember("token") || !doc["token"].IsString()) {
- return false;
- }else{
- token = doc["token"].GetString();
- }
- }
- return true;
- }
- };
|