Struct write_interface

Inheritance Relationships

Derived Types

Struct Documentation

struct write_interface

A helper class providing the necessary functionalities for: a) converting an object into JSON string. b) writing to a standard output stream in JSON format. c) writing to standard console in JSON format using overloaded ‘<<’ operator.

Note

: The JWT component classes inherits from this class to get the above functionalities.

Subclassed by jwt::jwt_header, jwt::jwt_payload

Friends

template<typename T, typename Cond>
friend std::string to_json_str(const T &obj, bool pretty)

Converts an object of type T

to its JSON string format.

For pretty print, pass second parameter as

true.

Note

: Type T must have a member function named create_json_obj. The check is made at compile time. Check meta::has_create_json_obj_member for more details. This check is done in Cond template parameter.

template<typename T>
friend std::ostream &write(std::ostream &os, const T &obj, bool pretty)

Writes the object of instance T in JSON format to standard output stream. The requirements on type T is same as that for to_json_str API.

template<typename T, typename Cond>
friend std::ostream &operator<<(std::ostream &os, const T &obj)

An overloaded operator for writing to standard ostream in JSON format. The requirements on type T is same as that for to_json_str API.

This API is same in functionality as that of write API. Only difference is that, there is no option to write the JSON representation in pretty format.