matador::json_mapper Class Reference

#include <json_mapper.hpp>

Public Member Functions

 json_mapper ()=default
 
std::string to_string (const json &js, const json_format &format=json_format::compact)
 
template<class T >
std::string to_string (const 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 >
json to_json (const T &obj)
 
json to_json (const std::string &str)
 
json to_json (const char *str)
 
template<class T >
to_object (const json &js)
 
template<class T >
std::vector< T > to_objects (const json &js)
 
template<class T >
to_object (const std::string &str)
 
template<class T >
to_object (const char *str)
 
template<class T >
std::vector< T > to_objects (const std::string &str)
 
template<class T >
std::vector< T > to_objects (const char *str)
 

Detailed Description

conversions string <-> json <-> object

string to_string(json) string to_string(object) string to_string(array<object>)

json to_json(object) json to_json(array<object>) json to_json(string)

object to_object(json) object to_object(string) array<object> to_objects(json) array<object> to_objects(string)

Constructor & Destructor Documentation

◆ json_mapper()

matador::json_mapper::json_mapper ( )
default

Default constructor

Member Function Documentation

◆ to_json() [1/3]

json matador::json_mapper::to_json ( const char *  str)

Converts the given json string into a json object.

Parameters
strJson string to convert
Returns
The json object

◆ to_json() [2/3]

json matador::json_mapper::to_json ( const std::string &  str)

Converts the given json string into a json object.

Parameters
strJson string to convert
Returns
The json object

◆ to_json() [3/3]

template<class T >
json matador::json_mapper::to_json ( const T &  obj)

Converts the given object into a json object.

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

◆ to_object() [1/3]

template<class T >
T matador::json_mapper::to_object ( const char *  str)

Convert a given json string into a concrete object

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

◆ to_object() [2/3]

template<class T >
T matador::json_mapper::to_object ( const json js)

Converts a given json object into the concrete object.

Template Parameters
TType of the object to create
Parameters
jsJson object to convert
Returns
The object created from the json object

◆ to_object() [3/3]

template<class T >
T matador::json_mapper::to_object ( const std::string &  str)

Convert a given json string into a concrete object

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

◆ to_objects() [1/3]

template<class T >
std::vector< T > matador::json_mapper::to_objects ( const char *  str)

Converts a given json string representing an array into a vector of objects.

Template Parameters
TType of the objects to create
Parameters
strJson array string to convert
Returns
The array of created objects

◆ to_objects() [2/3]

template<class T >
std::vector< T > matador::json_mapper::to_objects ( const json js)

Converts a json object of type array into an array concrete objects.

Template Parameters
TType of the objects to create
Parameters
jsJson to convert
Returns
The array of created objects

◆ to_objects() [3/3]

template<class T >
std::vector< T > matador::json_mapper::to_objects ( const std::string &  str)

Converts a given json string representing an array into a vector of objects.

Template Parameters
TType of the objects to create
Parameters
strJson array string to convert
Returns
The array of created objects

◆ to_string() [1/3]

std::string matador::json_mapper::to_string ( const json js,
const json_format format = json_format::compact 
)

Converts a given json object into a string where the format is defined by the given json format object.

Parameters
jsJson object to be converted
formatFormat of the output string
Returns
The json string

◆ to_string() [2/3]

template<class T >
std::string matador::json_mapper::to_string ( const std::vector< T > &  array,
const json_format format = json_format::compact 
)

Converts the given array of objects into a json string where the format is defined by the given json format object.

Template Parameters
TType of the objects to convert
Parameters
arrayArray of objects to convert
formatFormat of the output string
Returns
The json string

◆ to_string() [3/3]

template<class T >
std::string matador::json_mapper::to_string ( const T &  obj,
const json_format format = json_format::compact 
)

Converts the given object into a json string where the format is defined by the given json format object.

Template Parameters
TType of the object to convert
Parameters
objObject to convert
formatFormat of the output string
Returns
The json string

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