golang 的 json 处理库 json4g

码农软件 · 软件分类 · JSON/BSON开发包 · 2019-03-31 11:44:35

软件介绍

json4g 是 golang 的 json处理库,方便处理结构复杂的json文档。

json4g 提供了json的简便出来方法

方法介绍
1,LoadByString(string)    参数为json字符串,返回 JsonNode 对象指针
2,NowJsonNode(string,interface{})    参数节点名
3,NowJsonNodeByString(string,string)     参数 json字符串 如: {"a":"b","c":123}
4,AddNode(*JsonNode)     为某节点增加子节点 
5,DelNode(string)        某节点 删除指定名称子节点
6,ToJsonNode()          转JsonNode 指针对象
7,SetValue()            节点设置 节点值,可以为 数字,字符串,bool值,数组
8,GetNodeByPath(string) 通过路径查询 节点 如: {"a":{"b":{"c":123,"d":true}}} 节点c对象GetNodeByPath("a.b.c")
9,GetNodeByName(string) 通过节点名 查询 节点对象
10,ToString()            JsonNode对象转换为字符串
具体操作请参考 测试类 json4g_test.go

部分方法示例:

jsonStr := `{"STRING": "abcd","NUMBER":123456,"BOOL":false,"STRUCT":{"a":{"b":12345}},"array":["a","b","c"]}`
node, err := LoadByString(jsonStr)
if err == nil {
jnode := node.GetNodeByPath("STRUCT.a.b")
fmt.Println("STRUCT.a.b>>>>>>>", jnode.ValueNumber)
}
node.DelNode("NUMBER")  //删除
node.AddNode(NowJsonNode("name", "value"))  //增加
node.ToString()          // 转化为字符串

有问题或建议欢迎 email : donnie4w@gmail.com

本文地址:https://www.codercto.com/soft/d/2546.html

Introduction to the Design and Analysis of Algorithms

Introduction to the Design and Analysis of Algorithms

Anany Levitin / Addison Wesley / 2011-10-10 / USD 117.00

Based on a new classification of algorithm design techniques and a clear delineation of analysis methods, Introduction to the Design and Analysis of Algorithms presents the subject in a coherent a......一起来看看 《Introduction to the Design and Analysis of Algorithms》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换