|
MIRA
|
Classes | |
| class | JSONDefaultPrecision |
| JSONDefaultPrecision is a singleton that provides a mechanism to control the default precision for output of floating-point JSON values. More... | |
| struct | QueryNumberResult |
| A struct used for return value of getNumberElementIfExists() More... | |
| struct | QueryValueResult |
| A struct used for return value of getElementIfExists() More... | |
Typedefs | |
| typedef json_spirit::mValue | Value |
| A value is an abstract description of data in JSON (underlying data can either be one of the JSON base data types (int, double, string) or an json::Object, json::Array or null. More... | |
| typedef json_spirit::mObject | Object |
| A representation of an object (class, struct) in JSON. More... | |
| typedef json_spirit::mArray | Array |
| A representation of an array (vector) in JSON. More... | |
Functions | |
| void | write (const Value &value, std::ostream &ioStream, bool formatted=false, int precision=-1) |
| Writes a json::Value into a given stream using the JSON format. More... | |
| std::string | write (const Value &value, bool formatted=false, int precision=-1) |
| Writes a json::Value into a string using the JSON format. More... | |
| void | read (const std::string &s, Value &oValue) |
| Read a json::Value from a string that contains JSON format. More... | |
| void | read (std::istream &ioStream, Value &oValue) |
| Read a json::Value from a stream that contains JSON format. More... | |
| void | read (std::string::const_iterator &begin, std::string::const_iterator &end, Value &oValue) |
| Read a json::Value from a string iterator range that contains JSON format. More... | |
| Value | getElement (const Value &iValue, const std::string &elementName) |
| Get a json::Value element/member from a json::Value Syntax: More... | |
| bool | hasElement (const Value &iValue, const std::string &element) |
| Query existence of element/member in a json::Value Use this variant to only query whether the element exists, avoiding exceptions. More... | |
| QueryValueResult | getElementIfExists (const Value &iValue, const std::string &elementName) |
| Get a json::Value element/member from a json::Value if it exists, otherwise the returned result will contain the error string. More... | |
| double | getNumberElement (const Value &iValue, const std::string &elementName) |
| Get a number element/member from a json::Value See getElement() for basic syntax. More... | |
| bool | hasNumberElement (const Value &iValue, const std::string &element) |
| Query existence of number element/member in a json::Value Use this variant to only query whether the element exists and is a number, avoiding exceptions. More... | |
| QueryNumberResult | getNumberElementIfExists (const Value &iValue, const std::string &elementName) |
| Get a number element/member from a json::Value if it exists, otherwise the returned result will contain the error string. More... | |
| template<> | |
| std::string | cast< UUID > (const UUID &value) |
| template<> | |
| UUID | reverse_cast< UUID > (const std::string &value) |
| typedef json_spirit::mValue Value |
A value is an abstract description of data in JSON (underlying data can either be one of the JSON base data types (int, double, string) or an json::Object, json::Array or null.
| typedef json_spirit::mObject Object |
A representation of an object (class, struct) in JSON.
An object can have multiple members that are stored as named json::Value in a map.
| typedef json_spirit::mArray Array |
A representation of an array (vector) in JSON.
An array can have multiple items that are represented as json::Value in a vector.
| void mira::json::write | ( | const Value & | value, |
| std::ostream & | ioStream, | ||
| bool | formatted = false, |
||
| int | precision = -1 |
||
| ) |
Writes a json::Value into a given stream using the JSON format.
| value | The JSON value | |
| [in,out] | ioStream | The stream |
| formatted | If true indentations, spaces and line breaks are inserted | |
| precision | Decimal precision for output of floating-point values when writing value to stream (argument to std::setprecision). If < 0, query JSONDefaultPrecision. |
| std::string mira::json::write | ( | const Value & | value, |
| bool | formatted = false, |
||
| int | precision = -1 |
||
| ) |
Writes a json::Value into a string using the JSON format.
| value | The JSON value |
| formatted | If true indentations, spaces and line breaks are inserted when writing value to stream. |
| precision | Decimal precision for output of floating-point values when writing value to intermediate stream (argument to std::setprecision). If < 0, query JSONDefaultPrecision. |
| void mira::json::read | ( | const std::string & | s, |
| Value & | oValue | ||
| ) |
Read a json::Value from a string that contains JSON format.
| XIO | when string does not contain valid JSON format. |
| s | The string to convert | |
| [out] | oValue | The returned value as reference |
| void mira::json::read | ( | std::istream & | ioStream, |
| Value & | oValue | ||
| ) |
Read a json::Value from a stream that contains JSON format.
| XIO | when stream does not contain valid JSON format. |
| [in,out] | ioStream | The stream to convert |
| [out] | oValue | The returned value as reference |
|
inline |
Read a json::Value from a string iterator range that contains JSON format.
| XIO | when the range does not contain valid JSON format. |
| begin | The iterator pointing to the start of the range | |
| end | The iterator pointing to the end of the range | |
| [out] | oValue | The returned value as reference |
Get a json::Value element/member from a json::Value Syntax:
'Member' -> select element named 'Member' in value (must be a json::Object) '[i]' -> select ith array element in value (must be a json::Array) 'Member[i]' -> select array element in member element '.' -> nested selection, e.g. 'Member.SubMember' '[i].[j]' -> select array element in array element
example:
'A[0].[1].X.Y' -> member 'Y' of member 'X' of 2nd array element
of 1st array element of member 'A' of iValue (count starts at 0)iValue = {"A":[[1.000,{"X":{"Y":1}}],[2.500,3]]} --> return json::Value(1)
| XInvalidConfig | if the element could not be found or value is not an Object/Array. |
| [in] | iValue | The value to select the element from |
| [in] | elementName | The name of the element |
| bool mira::json::hasElement | ( | const Value & | iValue, |
| const std::string & | element | ||
| ) |
Query existence of element/member in a json::Value Use this variant to only query whether the element exists, avoiding exceptions.
See getElement() for syntax.
| [in] | iValue | The value to select the element from |
| [in] | elementName | The name of the element |
| QueryValueResult mira::json::getElementIfExists | ( | const Value & | iValue, |
| const std::string & | elementName | ||
| ) |
Get a json::Value element/member from a json::Value if it exists, otherwise the returned result will contain the error string.
Use this variant to avoid exceptions if the structure of iValue is unknown/not guaranteed. See getElement() for syntax.
| [in] | iValue | The value to select the element from |
| [in] | elementName | The name of the element |
| double mira::json::getNumberElement | ( | const Value & | iValue, |
| const std::string & | elementName | ||
| ) |
Get a number element/member from a json::Value See getElement() for basic syntax.
Additional syntax:
'[r][c]' -> select the specific matrix element at row/column
(must be a string value representing a 2D matrix in Eigen-like format)
This matrix element can only be a number, so there is no further nestingexample: 'M[1][0]' -> select row 2/column 1 from member 'M' (count starts at 0)
iValue = {"M":"[1,2,3;4,5,6]"} --> return 4
| XInvalidConfig | if the element could not be found, value is not an Object/Array/matrix representation or selected element is not a numerical/bool value. |
| [in] | iValue | The value to select the element from |
| [in] | elementName | The name of the element |
| bool mira::json::hasNumberElement | ( | const Value & | iValue, |
| const std::string & | element | ||
| ) |
Query existence of number element/member in a json::Value Use this variant to only query whether the element exists and is a number, avoiding exceptions.
See getNumberElement() for syntax.
| [in] | iValue | The value to select the element from |
| [in] | elementName | The name of the element |
| QueryNumberResult mira::json::getNumberElementIfExists | ( | const Value & | iValue, |
| const std::string & | elementName | ||
| ) |
Get a number element/member from a json::Value if it exists, otherwise the returned result will contain the error string.
Use this variant to avoid exceptions if the structure of iValue is unknown/not guaranteed. See getNumberElement() for syntax.
| [in] | iValue | The value to select the element from |
| [in] | elementName | The name of the element |
1.8.14