jwt_object API fixes

This commit is contained in:
Arun M 2017-11-23 17:24:56 +05:30
parent 0751d033dc
commit fc294cbc8a
7 changed files with 147 additions and 17 deletions

View file

@ -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() {