#include <json_object_mapper.hpp>
Public Member Functions | |
json_object_mapper ()=default | |
template<typename T > | |
std::string | to_string (const object_ptr< T > &obj, const json_format &format=json_format::compact) |
template<class T > | |
std::string | to_string (const std::vector< T > &array, const json_format &format=json_format::compact) |
template<class T > | |
std::string | to_string (const object_view< T > &array, const json_format &format=json_format::compact) |
template<typename T > | |
json | to_json (const object_ptr< T > &obj) |
template<class T > | |
json | to_json (const object_view< T > &objects) |
template<class T > | |
std::unique_ptr< T > | to_object (const json &js) |
template<class T > | |
std::vector< std::shared_ptr< T > > | to_objects (const json &js) |
template<class T > | |
std::unique_ptr< T > | to_object (const std::string &str) |
template<class T > | |
std::unique_ptr< T > | to_object (const char *str) |
template<class T > | |
std::vector< std::shared_ptr< T > > | to_objects (const std::string &str) |
template<class T > | |
std::vector< std::shared_ptr< T > > | to_objects (const char *str) |
conversions string <-> json <-> unique_ptr
string to_string(object_ptr) string to_string(object_view)
json to_json_string(object_ptr) json to_json_string(object_view)
unique_ptr to_object(json) unique_ptr to_object(string) array<shared_ptr> to_objects(json) array<shared_ptr> to_objects(string)
|
default |
Default constructor
json matador::json_object_mapper::to_json | ( | const object_ptr< T > & | obj | ) |
Convert an object_ptr, has_one or belongs_to object into an json object
T | Type of the object_ptr |
obj | Object to convert |
json matador::json_object_mapper::to_json | ( | const object_view< T > & | objects | ) |
Convert the elements of on object_view into a json object
T | Type of objects |
objects | object_view to convert |
std::unique_ptr< T > matador::json_object_mapper::to_object | ( | const char * | str | ) |
Convert a json string into a new object wrapped into a unique_ptr
T | Type of the object to create |
str | Json string to convert |
std::unique_ptr< T > matador::json_object_mapper::to_object | ( | const json & | js | ) |
Converts the json object into an object of a specific type
T | Type of the object to create |
js | json object to convert |
std::unique_ptr< T > matador::json_object_mapper::to_object | ( | const std::string & | str | ) |
Convert a json string into a new object wrapped into a unique_ptr
T | Type of the object to create |
str | Json string to convert |
std::vector< std::shared_ptr< T > > matador::json_object_mapper::to_objects | ( | const char * | str | ) |
Convert a json array string into a new array of objects wrapped into a unique_ptr
T | Type of the object to create |
str | Json string to convert |
std::vector< std::shared_ptr< T > > matador::json_object_mapper::to_objects | ( | const json & | js | ) |
Converts a json object of type array into a vector of shared_ptr object of given type
T | Type of the objects to create |
js | json object to convert |
std::vector< std::shared_ptr< T > > matador::json_object_mapper::to_objects | ( | const std::string & | str | ) |
Convert a json array string into a new array of objects wrapped into a unique_ptr
T | Type of the object to create |
str | Json string to convert |
std::string matador::json_object_mapper::to_string | ( | const object_ptr< T > & | obj, |
const json_format & | format = json_format::compact |
||
) |
Converts an object_ptr, has_one or belongs_to object into a json string with the given json format
T | Type of the object_ptr |
obj | Object to convert |
format | Json format object |
std::string matador::json_object_mapper::to_string | ( | const object_view< T > & | array, |
const json_format & | format = json_format::compact |
||
) |
Converts an object_view into a json string with the given json format
T | Type of objects |
array | object_view to convert |
format | Json format object |
std::string matador::json_object_mapper::to_string | ( | const std::vector< T > & | array, |
const json_format & | format = json_format::compact |
||
) |
Converts an array of objects into a json string with the given json format
T | Type of objects |
array | Array to convert |
format | Json format object |