TpJsonValue 类
V0.2.1TpUtils
2025-11-14
介绍
JSON值类,表示JSON中的各种数据类型
基础信息
| 头文件: | include <TpJsonValue.h> |
|---|---|
| Cmake: | None |
| 发布版本: | V0.2.1 |
| 继承类: | |
| 派生类: |
Public 属性
| 类型 | 名称 | 描述 |
|---|---|---|
| rapidjson::Value | value_ | 底层的rapidjson值对象 |
Public 成员函数
| TpJsonValue() | 默认构造函数,创建空值(Null) | |
|---|---|---|
| TpJsonValue(bool b) | 从布尔值构造JSON值 | |
| TpJsonValue(uint32_t i) | 从无符号32位整数构造JSON值 | |
| TpJsonValue(int32_t i) | 从有符号32位整数构造JSON值 | |
| TpJsonValue(int64_t i) | 从有符号64位整数构造JSON值 | |
| TpJsonValue(uint64_t i) | 从无符号64位整数构造JSON值 | |
| TpJsonValue(double d) | 从双精度浮点数构造JSON值 | |
| TpJsonValue(const char *str) | 从C字符串构造JSON值 | |
| TpJsonValue(const TpString &str) | 从字符串对象构造JSON值 | |
| TpJsonValue(const TpJsonValue &others) | 拷贝构造函数 | |
| isNull() const | 检查是否为空值(Null) | |
| isBool() const | 检查是否为布尔值 | |
| isInt() const | 检查是否为32位有符号整数 | |
| isUint() const | 检查是否为32位无符号整数 | |
| isInt64() const | 检查是否为64位有符号整数 | |
| isUint64() const | 检查是否为64位无符号整数 | |
| isDouble() const | 检查是否为双精度浮点数 | |
| isString() const | 检查是否为字符串 | |
| isObject() const | 检查是否为对象 | |
| isArray() const | 检查是否为数组 | |
| toBool() const | 转换为布尔值 | |
| toInt() const | 转换为32位有符号整数 | |
| toUint() const | 转换为32位无符号整数 | |
| toInt64() const | 转换为64位有符号整数 | |
| toUint64() const | 转换为64位无符号整数 | |
| toDouble() const | 转换为双精度浮点数 | |
| TpString | toString() const | 转换为字符串对象 |
| TpJsonObject | toObject() const | 转换为JSON对象 |
| TpJsonArray | toArray() const | 转换为JSON数组 |
| TpJsonValue & TpJsonValue::operator= | operator=(const TpJsonValue &others) | 赋值操作符 |
成员函数说明
TpJsonValue::TpJsonValue()
默认构造函数,创建空值(Null)...
默认构造函数,创建空值(Null)
TpJsonValue::TpJsonValue(bool b)
从布尔值构造JSON值...
从布尔值构造JSON值
参数:b: 布尔值
TpJsonValue::TpJsonValue(uint32_t i)
从无符号32位整数构造JSON值...
从无符号32位整数构造JSON值
参数:i: 无符号32位整数
TpJsonValue::TpJsonValue(int32_t i)
从有符号32位整数构造JSON值...
从有符号32位整数构造JSON值
参数:i: 有符号32位整数
TpJsonValue::TpJsonValue(int64_t i)
从有符号64位整数构造JSON值...
从有符号64位整数构造JSON值
参数:i: 有符号64位整数
TpJsonValue::TpJsonValue(uint64_t i)
从无符号64位整数构造JSON值...
从无符号64位整数构造JSON值
参数:i: 无符号64位整数
TpJsonValue::TpJsonValue(double d)
从双精度浮点数构造JSON值...
从双精度浮点数构造JSON值
参数:d: 双精度浮点数
TpJsonValue::TpJsonValue(const char *str)
从C字符串构造JSON值...
从C字符串构造JSON值
参数:str: C风格字符串
TpJsonValue::TpJsonValue(const TpString &str)
从字符串对象构造JSON值...
从字符串对象构造JSON值
参数:str: tpString字符串对象
TpJsonValue::TpJsonValue(const TpJsonValue &others)
拷贝构造函数...
拷贝构造函数
参数:others: 源JSON值
bool TpJsonValue::isNull() const
检查是否为空值(Null)...
检查是否为空值(Null)
bool TpJsonValue::isBool() const
检查是否为布尔值...
检查是否为布尔值
bool TpJsonValue::isInt() const
检查是否为32位有符号整数...
检查是否为32位有符号整数
bool TpJsonValue::isUint() const
检查是否为32位无符号整数...
检查是否为32位无符号整数
bool TpJsonValue::isInt64() const
检查是否为64位有符号整数...
检查是否为64位有符号整数
bool TpJsonValue::isUint64() const
检查是否为64位无符号整数...
检查是否为64位无符号整数
bool TpJsonValue::isDouble() const
检查是否为双精度浮点数...
检查是否为双精度浮点数
bool TpJsonValue::isString() const
检查是否为字符串...
检查是否为字符串
bool TpJsonValue::isObject() const
检查是否为对象...
检查是否为对象
bool TpJsonValue::isArray() const
检查是否为数组...
检查是否为数组
bool TpJsonValue::toBool() const
转换为布尔值...
转换为布尔值
返回值:转换后的布尔值
int32_t TpJsonValue::toInt() const
转换为32位有符号整数...
转换为32位有符号整数
返回值:转换后的整数
uint32_t TpJsonValue::toUint() const
转换为32位无符号整数...
转换为32位无符号整数
返回值:转换后的整数
int64_t TpJsonValue::toInt64() const
转换为64位有符号整数...
转换为64位有符号整数
返回值:转换后的整数
uint64_t TpJsonValue::toUint64() const
转换为64位无符号整数...
转换为64位无符号整数
返回值:转换后的整数
double TpJsonValue::toDouble() const
转换为双精度浮点数...
转换为双精度浮点数
返回值:转换后的浮点数
TpString TpJsonValue::toString() const
转换为字符串对象...
转换为字符串对象
返回值:转换后的字符串
TpJsonObject TpJsonValue::toObject() const
转换为JSON对象...
转换为JSON对象
返回值:转换后的JSON对象
TpJsonArray TpJsonValue::toArray() const
转换为JSON数组...
转换为JSON数组
返回值:转换后的JSON数组
TpJsonValue & TpJsonValue::operator=(const TpJsonValue &others)
赋值操作符...
赋值操作符
参数:others: 要复制的源JSON值
返回值:当前JSON值的引用
