json

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package json...

Description : 动态构建json

Author : go_developer@163.com<白茶清欢>

Date : 2021-03-10 10:26 下午

Package json ...

Description : 将复杂数据结构转化为 JSONNode 树

Author : go_developer@163.com<白茶清欢>

Date : 2021-03-14 10:40 下午

Index

Constants

View Source
const (
	// PathSplit json 路径的分割符
	PathSplit = "."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamicJSON

type DynamicJSON struct {
	// contains filtered or unexported fields
}

DynamicJSON 动态json

Author : go_developer@163.com<白茶清欢>

Date : 11:03 下午 2021/3/10

func NewDynamicJSON

func NewDynamicJSON() *DynamicJSON

NewDynamicJSON 获取JSON实例

Author : go_developer@163.com<白茶清欢>

Date : 10:36 下午 2021/3/10

func (*DynamicJSON) SetValue

func (dj *DynamicJSON) SetValue(path string, value interface{}, isComplexType bool)

SetValue 设置节点值,如果节点不存在,创建;如果已存在,更新, 多级key使用, value 必须是基础数据类型, 如果是结构体, 需要继续添加path,多级path使用.分割

Author : go_developer@163.com<白茶清欢>

Date : 10:45 下午 2021/3/10

func (*DynamicJSON) String

func (dj *DynamicJSON) String() string

String 获取字符串的格式JSON

Author : go_developer@163.com<白茶清欢>

Date : 2:16 下午 2021/3/11

type JSONode

type JSONode struct {
	Key              string      // json key
	Value            interface{} // 对应的值
	Child            []*JSONode  // 子节点
	IsRoot           bool        // 是否根节点
	IsHasLastBrother bool        // 在此之后是否有其他兄弟节点
	IsSlice          bool        // 是否是list
	IsIndexNode      bool        // 是否是slice的索引节点
	Sort             int         // 此属性用于 slice解析,保证最终排序是对的
	IsComplex        bool        // 是否为复杂数据类型
	IsString         bool        // 是否为字符串
}

JSONode JSOM节点

Author : go_developer@163.com<白茶清欢>

Date : 10:33 下午 2021/3/10

type ParseJSONTree

type ParseJSONTree struct {
	// contains filtered or unexported fields
}

ParseJSONTree 解析json树

Author : go_developer@163.com<白茶清欢>

Date : 10:41 下午 2021/3/14

func NewParseJSONTree

func NewParseJSONTree(data interface{}) *ParseJSONTree

NewParseJSONTree 获取解析的实例

Author : go_developer@163.com<白茶清欢>

Date : 10:43 下午 2021/3/14

func (*ParseJSONTree) Parse

func (pjt *ParseJSONTree) Parse(pathList []string) (*DynamicJSON, error)

Parse 解析数据

Author : go_developer@163.com<白茶清欢>

Date : 10:44 下午 2021/3/14

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL