mirror of
https://github.com/arun11299/cpp-jwt.git
synced 2025-05-15 09:18:33 +00:00
jwt_object API fixes
This commit is contained in:
parent
0751d033dc
commit
fc294cbc8a
7 changed files with 147 additions and 17 deletions
|
@ -1,4 +1,7 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "jwt/jwt.hpp"
|
||||
|
||||
void basic_jwt_object_test()
|
||||
|
@ -8,6 +11,27 @@ void basic_jwt_object_test()
|
|||
{"a", "b"},
|
||||
{"c", "d"}
|
||||
}));
|
||||
//check with std::map
|
||||
std::map<std::string, std::string> m;
|
||||
m["a"] = "b";
|
||||
m["c"] = "d";
|
||||
|
||||
jwt::jwt_object obj1{payload(m)};
|
||||
auto obj2 = std::move(obj1);
|
||||
|
||||
std::cout << obj2.payload() << std::endl;
|
||||
|
||||
//check with unordered map of string_view
|
||||
std::unordered_map<jwt::string_view, std::string> um = {
|
||||
{"a", "b"},
|
||||
{"c", "d"}
|
||||
};
|
||||
jwt::jwt_object obj3{payload(um)};
|
||||
|
||||
obj3.add_claim("f", true)
|
||||
.add_claim("time", 176353563);
|
||||
|
||||
std::cout << jwt::to_json_str(obj3.payload(), true) << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue