NettyHttpToken.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2021-11-04 09:39:46
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-02-23 10:24:10
  8. */
  9. #include <iostream>
  10. using namespace std;
  11. #include <rapidjson/document.h>
  12. #include <rapidjson/rapidjson.h>
  13. #include <rapidjson/stringbuffer.h>
  14. #include <rapidjson/writer.h>
  15. class NettyHttpToken
  16. {
  17. public:
  18. std::string authToken = "";
  19. std::string expiration = "";
  20. std::string refreshToken = "";
  21. public:
  22. NettyHttpToken() {}
  23. ~NettyHttpToken() {}
  24. /**
  25. * @description: json反序列为对象
  26. * @param {*}
  27. * @return {*}
  28. */
  29. bool jsonToObject(const rapidjson::Value& object){
  30. const auto end = object.MemberEnd();
  31. if(end == object.FindMember("authToken") || !object["authToken"].IsString()){
  32. return false;
  33. }else{
  34. authToken = object["authToken"].GetString();
  35. }
  36. if(end == object.FindMember("expiration") || !object["expiration"].IsString()){
  37. return false;
  38. }else{
  39. expiration = object["expiration"].GetString();
  40. }
  41. if(end == object.FindMember("refreshToken") || !object["refreshToken"].IsString()){
  42. return false;
  43. }else{
  44. refreshToken = object["refreshToken"].GetString();
  45. }
  46. return true;
  47. }
  48. };