Simox  2.3.74.0
simox::json Namespace Reference

Namespaces

 error
 

Typedefs

using json = nlohmann::json
 A JSON document. More...
 

Functions

Eigen::Matrix4f posquat2eigen4f (const std::string &str)
 
Eigen::Matrix4f posquat2eigen4f (const char *str)
 
Eigen::Matrix4f posquat2eigen4f (const simox::json::json &j)
 
std::vector< Eigen::Matrix4f > posquatArray2eigen4fVector (const std::string &str)
 
std::vector< Eigen::Matrix4f > posquatArray2eigen4fVector (const char *str)
 
std::vector< Eigen::Matrix4f > posquatArray2eigen4fVector (const simox::json::json &j)
 
std::string eigen4f2posquatJson (const Eigen::Matrix4f &str)
 
std::string eigen4fVector2posquatArrayJson (const std::vector< Eigen::Matrix4f > &str)
 
std::map< std::string, float > json2NameValueMap (const std::string &str)
 
std::map< std::string, float > json2NameValueMap (const char *str)
 
std::map< std::string, float > json2NameValueMap (const simox::json::json &j)
 
json read (const std::string &filename)
 Read a JSON document from the given file. More...
 
json read (std::istream &is)
 Read a JSON document from the given in-stream. More...
 
void write (const std::string &filename, const json &j, const int indent=-1, const char indent_char=' ')
 Write a JSON document to the given file. More...
 
void write (std::ostream &os, const json &j, const int indent=-1, const char indent_char=' ')
 Write a JSON document to the given out-stream. More...
 
template<class BO >
void write (const std::string &filename, const BO &bo, const int indent=-1, const char indent_char=' ')
 Write a business object as JSON to the given file. More...
 
json::const_reference at_any_key (const json &j, const std::vector< std::string > &keys)
 Get the value at the first key in keys contained in j. More...
 
template<class T >
get_at_any_key (const json &j, const std::vector< std::string > &keys)
 
template<class ValueT , class DefaultT = ValueT>
void get_to_if_exists (const json &j, const std::string &key, ValueT &dest, const DefaultT &default_=ValueT{})
 
template<typename Float >
void to_json (nlohmann::json &j, const OrientedBox< Float > &ob)
 
template<typename Float >
void from_json (const nlohmann::json &j, OrientedBox< Float > &ob)
 

Typedef Documentation

◆ json

A JSON document.

Function Documentation

◆ at_any_key()

json::json::const_reference simox::json::at_any_key ( const json j,
const std::vector< std::string > &  keys 
)

Get the value at the first key in keys contained in j.

Parameters
jThe JSON object.
keysThe keys.
Returns
The value at the first contained key.
Exceptions
std::out_of_rangeIf none of the keys is found in j.

◆ eigen4f2posquatJson()

std::string simox::json::eigen4f2posquatJson ( const Eigen::Matrix4f &  str)

◆ eigen4fVector2posquatArrayJson()

std::string simox::json::eigen4fVector2posquatArrayJson ( const std::vector< Eigen::Matrix4f > &  str)

◆ from_json()

template<typename Float >
void simox::json::from_json ( const nlohmann::json j,
OrientedBox< Float > &  ob 
)

◆ get_at_any_key()

template<class T >
T simox::json::get_at_any_key ( const json j,
const std::vector< std::string > &  keys 
)

◆ get_to_if_exists()

template<class ValueT , class DefaultT = ValueT>
void simox::json::get_to_if_exists ( const json j,
const std::string &  key,
ValueT &  dest,
const DefaultT &  default_ = ValueT{} 
)

◆ json2NameValueMap() [1/3]

std::map< std::string, float > simox::json::json2NameValueMap ( const std::string &  str)

◆ json2NameValueMap() [2/3]

std::map< std::string, float > simox::json::json2NameValueMap ( const char *  str)

◆ json2NameValueMap() [3/3]

std::map< std::string, float > simox::json::json2NameValueMap ( const simox::json::json j)

◆ posquat2eigen4f() [1/3]

Eigen::Matrix4f simox::json::posquat2eigen4f ( const std::string &  str)

◆ posquat2eigen4f() [2/3]

Eigen::Matrix4f simox::json::posquat2eigen4f ( const char *  str)

◆ posquat2eigen4f() [3/3]

Eigen::Matrix4f simox::json::posquat2eigen4f ( const simox::json::json j)

◆ posquatArray2eigen4fVector() [1/3]

std::vector< Eigen::Matrix4f > simox::json::posquatArray2eigen4fVector ( const std::string &  str)

◆ posquatArray2eigen4fVector() [2/3]

std::vector< Eigen::Matrix4f > simox::json::posquatArray2eigen4fVector ( const char *  str)

◆ posquatArray2eigen4fVector() [3/3]

std::vector< Eigen::Matrix4f > simox::json::posquatArray2eigen4fVector ( const simox::json::json j)

◆ read() [1/2]

BO simox::json::read ( const std::string &  filename)

Read a JSON document from the given file.

Read a JSON document from the given file and convert it to the business-object type BO.

Parameters
filenameThe name of the file to read from.
Returns
The JSON document.
Exceptions
<tt>simox::json::error::IOError</tt>If IO access fails.
<tt>simox::json::error::ParseError</tt>If parsing fails.
Parameters
filenameThe name of the file to read from.
Returns
The business object.
Exceptions
<tt>simox::json::error::IOError</tt>If IO access fails.
<tt>simox::json::error::ParseError</tt>If parsing fails.
<tt>simox::json::error::ConversionError</tt>If converting the JSON document to the BO fails.

◆ read() [2/2]

json::json simox::json::read ( std::istream &  is)

Read a JSON document from the given in-stream.

Parameters
isThe in-stream.
Returns
The JSON document.
Exceptions
<tt>simox::json::error::ParseError</tt>If parsing fails.

◆ to_json()

template<typename Float >
void simox::json::to_json ( nlohmann::json j,
const OrientedBox< Float > &  ob 
)

◆ write() [1/3]

void simox::json::write ( const std::string &  filename,
const json j,
const int  indent = -1,
const char  indent_char = ' ' 
)

Write a JSON document to the given file.

Parameters
filenameThe name of the file to write to.
jThe JSON document.
indentSee nlohmann::json::dump().
indent_charSee nlohmann::json::dump().
Exceptions
<tt>simox::json::error::IOError</tt>If IO access fails.

◆ write() [2/3]

void simox::json::write ( std::ostream &  os,
const json j,
const int  indent = -1,
const char  indent_char = ' ' 
)

Write a JSON document to the given out-stream.

Parameters
osThe out-stream.
jThe JSON document.
indentThe number of indents, if nonnegative (see nlohmann::json::dump()).
indent_charThe character used for indents (see nlohmann::json::dump()).

◆ write() [3/3]

template<class BO >
void simox::json::write ( const std::string &  filename,
const BO &  bo,
const int  indent = -1,
const char  indent_char = ' ' 
)

Write a business object as JSON to the given file.

Parameters
filenameThe name of the file to write to.
boThe business object.
indentThe number of indents, if nonnegative (see nlohmann::json::dump()).
indent_charThe character used for indents (see nlohmann::json::dump()).
Exceptions
<tt>simox::json::error::IOError</tt>If IO access fails.
<tt>simox::json::error::ConversionError</tt>If the bo could not access fails.