Skip to content

包函数

json 包提供的顶级函数,无需创建 Processor 实例即可直接调用。按功能分类如下:

查询获取

路径查询、类型安全获取、安全获取和批量获取函数。

主要函数Get · GetWithContext · GetString · GetInt · GetFloat · GetBool · GetArray · GetObject · GetTyped[T] · SafeGet · GetMultiple

修改操作

设置、合并 JSON 数据的函数。

主要函数Set · SetMultiple · SetCreate · SetMultipleCreate · MergeJSON · MergeMany

删除操作

删除 JSON 数据节点的函数。

主要函数Delete · DeleteClean

编码输出

序列化、反序列化、流式编码解码函数。

主要函数Marshal · Unmarshal · MarshalIndent · Encode · EncodePretty · EncodeWithConfig · Prettify · Compact · CompactString · Indent · HTMLEscape · NewEncoder · NewDecoder · EncodeBatch · EncodeFields · EncodeStream · SaveToWriter

解析验证

解析 JSON 到目标对象、Processor 实例解析和 JSON 有效性/Schema 验证函数。

主要函数Parse · ParseAny · Processor.Parse · Processor.ParseAny · Valid · ValidWithConfig · ValidateSchema

批量操作

批量处理多个 JSON 操作(get/set/delete/validate)的函数。

主要函数ProcessBatch · BatchOperation · BatchResult

JSONL

JSONL(JSON Lines)解析、流式读取、转换和写入函数。

主要函数ParseJSONL · ToJSONL · ToJSONLString · StreamLinesInto[T] · NewJSONLWriter

文件操作

文件读写和流式 I/O 函数。

主要函数LoadFromFile · LoadFromReader · SaveToFile · MarshalToFile · UnmarshalFromFile · SaveToWriter

迭代方法

遍历 JSON 数组、对象、嵌套结构与文件的迭代函数。

主要函数Foreach · ForeachWithPath · ForeachNested · ForeachReturn · ForeachWithError · ForeachNestedWithError · ForeachWithPathAndIterator · ForeachWithPathAndControl · ForeachFile · ForeachFileWithPath · ForeachFileChunked · ForeachFileNested

文件迭代

文件流式迭代场景指南与实践(包级 ForeachFile* 函数的 API 参考见 迭代方法)。

主要函数ForeachFile · ForeachFileWithPath · ForeachFileChunked · ForeachFileNested

辅助工具

类型转换、比较、缓存管理、错误处理等工具函数。

主要函数CompareJSON · MergeJSON · MergeMany · ClearCache · GetStats · GetHealthStatus · SetGlobalProcessor · ShutdownGlobalProcessor · SafeError · RedactedPath · WarmupCache


快速导航

用途推荐函数文档
获取单个值GetString, GetInt, GetFloat, GetBool查询获取
获取任意类型Get, GetTyped[T]查询获取
带默认值获取GetString(data, path, "default")查询获取
泛型获取GetTyped[T](data, path, defaultValue...)查询获取
批量获取GetMultiple查询获取
修改 JSONSet, SetCreate修改操作
删除 JSONDelete, DeleteClean删除操作
序列化Marshal, Encode编码输出
反序列化Unmarshal, Parse编码输出 · 解析验证
格式化Prettify, CompactString, Processor.Compact编码输出
打印输出Encode + fmt.Println, EncodePretty打印函数
批量编码EncodeBatch, EncodeFields, EncodeStream批量编码 · 处理器输出
批量操作ProcessBatch批量操作
验证Valid解析验证
JSON Schema 验证ValidateSchema解析验证
文件读写LoadFromFile, SaveToFile文件操作
迭代遍历Foreach, ForeachWithPath, ForeachNested迭代方法
文件迭代ForeachFile, ForeachFileChunked迭代方法
JSONL 处理ParseJSONL, ToJSONLJSONL
比较CompareJSON辅助工具
合并MergeJSON, MergeMany修改操作
类型转换AccessResult 类型转换方法辅助工具
错误处理JsonsError, errors.Is常量错误

相关