class of solving json data
More...
#include <sttnet_English.h>
|
| static int | getValue (const std::string &oriStr, std::string &result, const std::string &type="value", const std::string &name="a", const int &num=0) |
| | Extract the value or nested structure of a specified field in a JSON string. More...
|
| |
| static std::string | toString (const Json::Value &val) |
| | Convert Json::Value to a string. More...
|
| |
| static Json::Value | toJsonArray (const std::string &str) |
| | Parse a JSON string into Json::Value. More...
|
| |
| template<class T1 , class T2 > |
| static std::string | createJson (T1 first, T2 second) |
| | Create a JSON string containing only one key-value pair. More...
|
| |
| template<class T1 , class T2 , class... Args> |
| static std::string | createJson (T1 first, T2 second, Args...args) |
| | Create a JSON string composed of multiple key-value pairs (recursive variadic template). More...
|
| |
| template<class T > |
| static std::string | createArray (T first) |
| | Create a JSON array string containing only one element. More...
|
| |
| template<class T , class... Args> |
| static std::string | createArray (T first, Args...args) |
| | Create a JSON array string composed of multiple elements (recursive variadic template). More...
|
| |
| static std::string | jsonAdd (const std::string &a, const std::string &b) |
| | Concatenate two JSON strings into a valid JSON (suitable for object or array concatenation). More...
|
| |
| static std::string & | jsonFormatify (const std::string &a, std::string &b) |
| | Remove indentation, spaces, etc., from a formatted JSON string to make it compact. More...
|
| |
| static std::string & | jsonToUTF8 (const std::string &input, std::string &output) |
| | Convert in a JSON string to UTF-8 characters. More...
|
| |
class of solving json data
template<class T >
| static std::string stt::data::JsonHelper::createArray |
( |
T |
first | ) |
|
|
inlinestatic |
Create a JSON array string containing only one element.
- Parameters
-
| T | Any type. |
| first | The first element. |
- Returns
- std::string JSON array string.
template<class T , class... Args>
| static std::string stt::data::JsonHelper::createArray |
( |
T |
first, |
|
|
Args... |
args |
|
) |
| |
|
inlinestatic |
Create a JSON array string composed of multiple elements (recursive variadic template).
- Parameters
-
| T | Type of the first element. |
| Args | Types of the remaining elements. |
| first | The first element. |
| args | The remaining elements. |
- Returns
- std::string The concatenated JSON array string.
template<class T1 , class T2 >
| static std::string stt::data::JsonHelper::createJson |
( |
T1 |
first, |
|
|
T2 |
second |
|
) |
| |
|
inlinestatic |
Create a JSON string containing only one key-value pair.
- Parameters
-
| T1 | Type of the key, usually std::string. |
| T2 | Type of the value, can be any type acceptable to Json::Value. |
| first | Key. |
| second | Value. |
- Returns
- std::string JSON string.
template<class T1 , class T2 , class... Args>
| static std::string stt::data::JsonHelper::createJson |
( |
T1 |
first, |
|
|
T2 |
second, |
|
|
Args... |
args |
|
) |
| |
|
inlinestatic |
Create a JSON string composed of multiple key-value pairs (recursive variadic template).
- Parameters
-
| T1 | Type of the first key. |
| T2 | Type of the first value. |
| Args | The remaining key-value parameters in pairs. |
| first | The first key. |
| second | The first value. |
| args | The remaining key-value parameters. |
- Returns
- std::string The concatenated JSON string.
| static int stt::data::JsonHelper::getValue |
( |
const std::string & |
oriStr, |
|
|
std::string & |
result, |
|
|
const std::string & |
type = "value", |
|
|
const std::string & |
name = "a", |
|
|
const int & |
num = 0 |
|
) |
| |
|
static |
Extract the value or nested structure of a specified field in a JSON string.
- Parameters
-
| oriStr | raw JSON string. |
| result | stores a string reference to the return value. |
| type | mode, optional values: value, arrayvalue. They are the values in ordinary JSON objects and the values in array objects. |
| name | key name in JSON (value only). |
| num | array index position (starting from 0) (for arrayvalue only). |
- Returns
- -1: Extraction failed 0: Returns a non-JSON object 1: Returns a JSON object
| static std::string stt::data::JsonHelper::jsonAdd |
( |
const std::string & |
a, |
|
|
const std::string & |
b |
|
) |
| |
|
static |
Concatenate two JSON strings into a valid JSON (suitable for object or array concatenation).
- Parameters
-
| a | The first JSON string. |
| b | The second JSON string. |
- Returns
- std::string Concatenated JSON string.
| static std::string& stt::data::JsonHelper::jsonFormatify |
( |
const std::string & |
a, |
|
|
std::string & |
b |
|
) |
| |
|
static |
Remove indentation, spaces, etc., from a formatted JSON string to make it compact.
- Parameters
-
| a | Input JSON string. |
| b | Reference to store the formatted result. |
- Returns
- std::string& Reference to the compact format string.
| static std::string& stt::data::JsonHelper::jsonToUTF8 |
( |
const std::string & |
input, |
|
|
std::string & |
output |
|
) |
| |
|
static |
Convert in a JSON string to UTF-8 characters.
- Parameters
-
| input | JSON string with Unicode encoding. |
| output | Reference to store the converted string. |
- Returns
- std::string& Reference to the converted string.
| static Json::Value stt::data::JsonHelper::toJsonArray |
( |
const std::string & |
str | ) |
|
|
static |
Parse a JSON string into Json::Value.
- Parameters
-
- Returns
- Json::Value Parsed JSON object or array.
| static std::string stt::data::JsonHelper::toString |
( |
const Json::Value & |
val | ) |
|
|
static |
Convert Json::Value to a string.
- Parameters
-
- Returns
- std::string String form of the value.
The documentation for this class was generated from the following file: