From 42310e634dff8f7fcdfefe2350d613b1188fcbf9 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Tue, 24 Mar 2020 09:09:41 -0400 Subject: [PATCH] adding stream operators to claims easier to parse and output claims --- include/jwt-cpp/jwt.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index 82504a7..7e8a921 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -803,6 +803,15 @@ namespace jwt { return val; } + /** + * Parse input stream into wrapped json object + * \return input stream + */ + inline std::istream& operator>>(std::istream& is) + { + return is >> val; + } + /** * Get type of contained object * \return Type @@ -1588,3 +1597,14 @@ namespace jwt { return decoded_jwt(token); } } + + +inline std::istream& operator>>(std::istream& is, jwt::claim c) +{ + return c.operator>>(is); +} + +inline std::ostream& operator<<(std::ostream& os, jwt::claim c) +{ + return os << c.to_json(); +}