NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::serialize::json_serializer类 参考

JSON 序列化器 更多...

#include <json_serializer.hpp>

静态 Public 成员函数

static unique_ptr< json_valueserialize (const reflect::meta_any &obj, const serialize_context &ctx={})
 将反射对象序列化为 JSON 值树
static string to_string (const reflect::meta_any &obj, const serialize_context &ctx={})
 将反射对象序列化为 JSON 字符串
static reflect::meta_any deserialize (const json_value &value, const reflect::meta_type &type, const serialize_context &ctx={})
 从 JSON 值树反序列化对象
static reflect::meta_any from_string (const string &json_str, const reflect::meta_type &type, const serialize_context &ctx={})
 从 JSON 字符串反序列化对象

详细描述

JSON 序列化器

将反射注册的对象转换为 JSON 表示,或从 JSON 重建对象。 自动遍历 meta_type 的属性列表,跳过暂态属性。

在文件 json_serializer.hpp30 行定义.

成员函数说明

◆ deserialize()

reflect::meta_any neforce::serialize::json_serializer::deserialize ( const json_value & value,
const reflect::meta_type & type,
const serialize_context & ctx = {} )
static

从 JSON 值树反序列化对象

参数
valueJSON 值树
type目标类型元数据
ctx序列化上下文
返回
重建的对象

◆ from_string()

reflect::meta_any neforce::serialize::json_serializer::from_string ( const string & json_str,
const reflect::meta_type & type,
const serialize_context & ctx = {} )
static

从 JSON 字符串反序列化对象

参数
json_strJSON 字符串
type目标类型元数据
ctx序列化上下文
返回
重建的对象

◆ serialize()

unique_ptr< json_value > neforce::serialize::json_serializer::serialize ( const reflect::meta_any & obj,
const serialize_context & ctx = {} )
static

将反射对象序列化为 JSON 值树

参数
obj要序列化的对象
ctx序列化上下文
返回
JSON 值树的根节点

◆ to_string()

string neforce::serialize::json_serializer::to_string ( const reflect::meta_any & obj,
const serialize_context & ctx = {} )
static

将反射对象序列化为 JSON 字符串

参数
obj要序列化的对象
ctx序列化上下文
返回
JSON 字符串

该类的文档由以下文件生成: