|
STTNet 0.7.0
|
json数据操作类 更多...
#include <sttnet.h>
静态 Public 成员函数 | |
| static int | getValue (const std::string &oriStr, std::string &result, const std::string &type="value", const std::string &name="a", const int &num=0) |
| 提取 JSON 字符串中指定字段的值或嵌套结构。 | |
| static std::string | toString (const Json::Value &val) |
| 将 Json::Value 序列化为紧凑 JSON 文本。 | |
| static Json::Value | toJsonArray (const std::string &str) |
| 解析 JSON 字符串为 Json::Value。 | |
| template<class T1, class T2> | |
| static std::string | createJson (T1 first, T2 second) |
| 创建仅包含一个键值对的 JSON 字符串。 | |
| template<class T1, class T2, class... Args> | |
| static std::string | createJson (T1 first, T2 second, Args... args) |
| 创建多个键值对组成的 JSON 字符串(递归变参模板)。 | |
| template<class T> | |
| static std::string | createArray (T first) |
| 创建只包含一个元素的 JSON 数组字符串。 | |
| template<class T, class... Args> | |
| static std::string | createArray (T first, Args... args) |
| 创建多个元素组成的 JSON 数组字符串(递归变参模板)。 | |
| static std::string | jsonAdd (const std::string &a, const std::string &b) |
| 将两个 JSON 字符串拼接为一个有效的 JSON(适用于对象或数组拼接)。 | |
| static std::string & | jsonFormatify (const std::string &a, std::string &b) |
| 将格式化后的 JSON 字符串去除缩进、空格等变成紧凑格式。 | |
| static std::string & | jsonToUTF8 (const std::string &input, std::string &output) |
| 将 JSON 字符串中的 Unicode 转义序列转换为 UTF-8 字符。 | |
json数据操作类
|
inlinestatic |
创建只包含一个元素的 JSON 数组字符串。
| T | 任意类型。 |
| first | 第一个元素。 |
|
inlinestatic |
创建多个元素组成的 JSON 数组字符串(递归变参模板)。
| T | 第一个元素类型。 |
| Args | 其余元素类型。 |
| first | 第一个元素。 |
| args | 其余元素。 |
|
inlinestatic |
创建仅包含一个键值对的 JSON 字符串。
| T1 | 键的类型,通常为 std::string。 |
| T2 | 值的类型,可为任意可被 Json::Value 接收的类型。 |
| first | 键。 |
| second | 值。 |
|
inlinestatic |
创建多个键值对组成的 JSON 字符串(递归变参模板)。
| T1 | 第一个键的类型。 |
| T2 | 第一个值的类型。 |
| Args | 其余成对出现的键值参数类型。 |
| first | 第一个键。 |
| second | 第一个值。 |
| args | 其余键值参数。 |
|
static |
提取 JSON 字符串中指定字段的值或嵌套结构。
| oriStr | 原始 JSON 字符串。 |
| result | 存储返回值的字符串引用。 |
| type | 类型模式,可选值:value, arrayvalue。分别为普通json对象里面的值,数组对象里面的值。 |
| name | JSON 中的键名(仅适用于 value)。 |
| num | 数组索引位置(从0开始)(仅适用于 arrayvalue)。 |
|
static |
将两个 JSON 字符串拼接为一个有效的 JSON(适用于对象或数组拼接)。
| a | 第一个 JSON 字符串。 |
| b | 第二个 JSON 字符串。 |
|
static |
将格式化后的 JSON 字符串去除缩进、空格等变成紧凑格式。
| a | 输入的 JSON 字符串。 |
| b | 存储格式化结果的引用。 |
|
static |
将 JSON 字符串中的 Unicode 转义序列转换为 UTF-8 字符。
| input | 含有 Unicode 编码的 JSON 字符串。 |
| output | 存储转换后字符串的引用。 |
|
static |
解析 JSON 字符串为 Json::Value。
| str | 输入的 JSON 字符串。 |
|
static |
将 Json::Value 序列化为紧凑 JSON 文本。
| val | JSON 值。 |