tpJsonObject类
Utils
2025-07-05
介绍
JSON对象类,提供完整的JSON对象操作功能
基础信息
头文件: | include <tpJsonObject.h> |
---|---|
Cmake: | None |
发布版本: | V0.1.0 |
继承类: | |
派生类: |
Public 成员函数
tpJsonObject() | 默认构造函数,创建空JSON对象 | |
---|---|---|
tpJsonObject(const tpJsonObject &others) | 拷贝构造函数 | |
tpList< tpString > | keys() const | 获取JSON对象中所有键的列表 |
isEmpty() const | 检查JSON对象是否为空 | |
contains(const tpString &key) const | 检查JSON对象是否包含指定键 | |
insert(const tpString &key, const tpJsonValue &value) | 插入JSON键值对(值类型为JsonValue) | |
insert(const tpString &key, const tpJsonObject &value) | 插入JSON键值对(值类型为JsonObject) | |
insert(const tpString &key, const tpJsonArray &value) | 插入JSON键值对(值类型为JsonArray) | |
tpJsonValue | value(const tpString &key) | 获取指定键对应的JSON值 |
remove(const tpString &key) | 移除JSON对象中的指定键及其值 | |
tpJsonObject & tpJsonObject::operator= | operator=(const tpJsonObject &others) | 赋值操作符 |
成员函数说明
tpJsonObject::tpJsonObject()
点击查看...
默认构造函数,创建空JSON对象
tpJsonObject::tpJsonObject(const tpJsonObject &others)
点击查看...
拷贝构造函数
tpList< tpString > tpJsonObject::keys() const
点击查看...
获取JSON对象中所有键的列表
返回值:
键列表
bool tpJsonObject::isEmpty() const
点击查看...
检查JSON对象是否为空
返回值:
空对象返回true,否则返回false
bool tpJsonObject::contains(const tpString &key) const
点击查看...
检查JSON对象是否包含指定键
返回值:
存在返回true,否则返回false
void tpJsonObject::insert(const tpString &key, const tpJsonValue &value)
点击查看...
插入JSON键值对(值类型为JsonValue)
返回值:
如果key已存在,则覆盖原有值
void tpJsonObject::insert(const tpString &key, const tpJsonObject &value)
点击查看...
插入JSON键值对(值类型为JsonObject)
返回值:
如果key已存在,则覆盖原有值
void tpJsonObject::insert(const tpString &key, const tpJsonArray &value)
点击查看...
插入JSON键值对(值类型为JsonArray)
返回值:
如果key已存在,则覆盖原有值
tpJsonValue tpJsonObject::value(const tpString &key)
点击查看...
获取指定键对应的JSON值
返回值:
对应的JSON值
void tpJsonObject::remove(const tpString &key)
点击查看...
移除JSON对象中的指定键及其值
tpJsonObject & tpJsonObject::operator=(const tpJsonObject &others)
点击查看...
赋值操作符
返回值:
当前JSON对象的引用