12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*
- * @Description:
- * @Version: 1.0
- * @Autor: lishengyin
- * @Date: 2021-11-04 09:39:46
- * @LastEditors: Your Name lishengyin@sz-sunwin.com
- * @LastEditTime: 2022-09-04 21:26:21
- */
- #ifndef __HTTPTOKEN_HPP_
- #define __HTTPTOKEN_HPP_
- #include <iostream>
- using namespace std;
- #include <rapidjson/document.h>
- #include <rapidjson/rapidjson.h>
- #include <rapidjson/stringbuffer.h>
- #include <rapidjson/writer.h>
- class HttpToken
- {
- public:
- std::string authToken = "";
- std::string expiration = "";
- std::string refreshToken = "";
-
- public:
- HttpToken() {}
- ~HttpToken() {}
-
- /**
- * @description: json反序列为对象
- * @param {*}
- * @return {*}
- */
- bool jsonToObject(const rapidjson::Value& object){
- const auto end = object.MemberEnd();
- if(end == object.FindMember("authToken") || !object["authToken"].IsString()){
- return false;
- }else{
- authToken = object["authToken"].GetString();
- }
- if(end == object.FindMember("expiration") || !object["expiration"].IsString()){
- return false;
- }else{
- expiration = object["expiration"].GetString();
- }
- if(end == object.FindMember("refreshToken") || !object["refreshToken"].IsString()){
- return false;
- }else{
- refreshToken = object["refreshToken"].GetString();
- }
- return true;
- }
- void ObjectToJson(rapidjson::Writer<rapidjson::StringBuffer>& writer){
- writer.StartObject();
- writer.EndObject();
- }
- };
- #endif
|