matador::json_object_mapper Class Reference

#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)
 

Detailed Description

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)

Constructor & Destructor Documentation

◆ json_object_mapper()

matador::json_object_mapper::json_object_mapper ( )
default

Default constructor

Member Function Documentation

◆ to_json() [1/2]

template<typename T >
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

Template Parameters
TType of the object_ptr
Parameters
objObject to convert
Returns
The json object

◆ to_json() [2/2]

template<class T >
json matador::json_object_mapper::to_json ( const object_view< T > &  objects)

Convert the elements of on object_view into a json object

Template Parameters
TType of objects
Parameters
objectsobject_view to convert
Returns
The json object

◆ to_object() [1/3]

template<class T >
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

Template Parameters
TType of the object to create
Parameters
strJson string to convert
Returns

◆ to_object() [2/3]

template<class T >
std::unique_ptr< T > matador::json_object_mapper::to_object ( const json js)

Converts the json object into an object of a specific type

Template Parameters
TType of the object to create
Parameters
jsjson object to convert
Returns
The newly created object as unique_ptr

◆ to_object() [3/3]

template<class T >
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

Template Parameters
TType of the object to create
Parameters
strJson string to convert
Returns

◆ to_objects() [1/3]

template<class T >
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

Template Parameters
TType of the object to create
Parameters
strJson string to convert
Returns
Array of created objects

◆ to_objects() [2/3]

template<class T >
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

Template Parameters
TType of the objects to create
Parameters
jsjson object to convert
Returns
The vector of created objects

◆ to_objects() [3/3]

template<class T >
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

Template Parameters
TType of the object to create
Parameters
strJson string to convert
Returns
Array of created objects

◆ to_string() [1/3]

template<typename T >
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

Template Parameters
TType of the object_ptr
Parameters
objObject to convert
formatJson format object
Returns
The json formatted string

◆ to_string() [2/3]

template<class T >
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

Template Parameters
TType of objects
Parameters
arrayobject_view to convert
formatJson format object
Returns
The json formatted string

◆ to_string() [3/3]

template<class T >
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

Template Parameters
TType of objects
Parameters
arrayArray to convert
formatJson format object
Returns
The json formatted string

The documentation for this class was generated from the following file:
  • matador/object/json_object_mapper.hpp