update
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : 动态构建json
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-03-10 10:26 下午
|
||||
package json
|
||||
@ -24,7 +24,7 @@ const (
|
||||
|
||||
// JSONode JSOM节点
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:33 下午 2021/3/10
|
||||
type JSONode struct {
|
||||
@ -42,7 +42,7 @@ type JSONode struct {
|
||||
|
||||
// NewDynamicJSON 获取JSON实例
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:36 下午 2021/3/10
|
||||
func NewDynamicJSON() *DynamicJSON {
|
||||
@ -62,7 +62,7 @@ func NewDynamicJSON() *DynamicJSON {
|
||||
|
||||
// DynamicJSON 动态json
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:03 下午 2021/3/10
|
||||
type DynamicJSON struct {
|
||||
@ -74,7 +74,7 @@ type DynamicJSON struct {
|
||||
|
||||
// SetValue 设置节点值,如果节点不存在,创建;如果已存在,更新, 多级key使用, value 必须是基础数据类型, 如果是结构体, 需要继续添加path,多级path使用.分割
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:45 下午 2021/3/10
|
||||
func (dj *DynamicJSON) SetValue(path string, value interface{}, isComplexType bool) {
|
||||
@ -102,7 +102,7 @@ func (dj *DynamicJSON) SetValue(path string, value interface{}, isComplexType bo
|
||||
|
||||
// String 获取字符串的格式JSON
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2:16 下午 2021/3/11
|
||||
func (dj *DynamicJSON) String() string {
|
||||
@ -114,7 +114,7 @@ func (dj *DynamicJSON) String() string {
|
||||
|
||||
// buildTpl 构建json模版与绑定数据
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 4:38 下午 2021/3/11
|
||||
func (dj *DynamicJSON) buildTpl(root *JSONode, tplList *[]string, valList *[]interface{}) (*[]string, *[]interface{}) {
|
||||
@ -151,7 +151,7 @@ func (dj *DynamicJSON) buildTpl(root *JSONode, tplList *[]string, valList *[]int
|
||||
|
||||
// getValFormat 构建值得占位符
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:49 下午 2021/3/13
|
||||
func (dj *DynamicJSON) getValFormat(root *JSONode) string {
|
||||
@ -181,7 +181,7 @@ func (dj *DynamicJSON) getValFormat(root *JSONode) string {
|
||||
|
||||
// getStartSymbol 计算起始的符号
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:21 下午 2021/3/13
|
||||
func (dj *DynamicJSON) getStartSymbol(root *JSONode) string {
|
||||
@ -216,7 +216,7 @@ func (dj *DynamicJSON) getStartSymbol(root *JSONode) string {
|
||||
|
||||
// getEndSymbol 计算结束的符号
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:21 下午 2021/3/13
|
||||
func (dj *DynamicJSON) getEndSymbol(root *JSONode) string {
|
||||
@ -246,7 +246,7 @@ func (dj *DynamicJSON) getEndSymbol(root *JSONode) string {
|
||||
|
||||
// Search 搜索一个key TODO : 优化
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:19 下午 2021/3/10
|
||||
func (dj *DynamicJSON) search(root *JSONode, key string) *JSONode {
|
||||
@ -266,7 +266,7 @@ func (dj *DynamicJSON) search(root *JSONode, key string) *JSONode {
|
||||
|
||||
// createNode 创建新的节点
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:57 下午 2021/3/10
|
||||
func (dj *DynamicJSON) createNode(parent *JSONode, key string, value interface{}, isComplexType bool) error {
|
||||
@ -309,7 +309,7 @@ func (dj *DynamicJSON) createNode(parent *JSONode, key string, value interface{}
|
||||
|
||||
// extraSliceIndex 抽取slice索引
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:37 下午 2021/3/11
|
||||
func (dj *DynamicJSON) extraSliceIndex(key string) (bool, int) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : json...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-03-10 11:44 下午
|
||||
package json
|
||||
@ -14,7 +14,7 @@ import (
|
||||
|
||||
// TestJSON ...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:58 下午 2021/3/14
|
||||
func TestJSON(t *testing.T) {
|
||||
@ -42,7 +42,7 @@ func TestJSON(t *testing.T) {
|
||||
|
||||
// TestType 判断数据类型断言
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:59 下午 2021/3/14
|
||||
func TestType(t *testing.T) {
|
||||
@ -51,7 +51,7 @@ func TestType(t *testing.T) {
|
||||
|
||||
// TestSelect 测试动态选择字段
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:47 下午 2021/4/13
|
||||
func TestSelect(t *testing.T) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : 将复杂数据结构转化为 JSONNode 树
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-03-14 10:40 下午
|
||||
package json
|
||||
@ -22,7 +22,7 @@ import (
|
||||
|
||||
// NewParseJSONTree 获取解析的实例
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:43 下午 2021/3/14
|
||||
func NewParseJSONTree(data interface{}) *ParseJSONTree {
|
||||
@ -31,7 +31,7 @@ func NewParseJSONTree(data interface{}) *ParseJSONTree {
|
||||
|
||||
// ParseJSONTree 解析json树
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:41 下午 2021/3/14
|
||||
type ParseJSONTree struct {
|
||||
@ -40,7 +40,7 @@ type ParseJSONTree struct {
|
||||
|
||||
// Parse 解析数据
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:44 下午 2021/3/14
|
||||
func (pjt *ParseJSONTree) Parse(pathList []string) (*DynamicJSON, error) {
|
||||
@ -77,7 +77,7 @@ func (pjt *ParseJSONTree) Parse(pathList []string) (*DynamicJSON, error) {
|
||||
|
||||
// isLegalData 判断是否能转换成json结构, 只有slice/map/struct/能转换成slice或map的[]byte是合法的
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:46 下午 2021/3/14
|
||||
func (pjt *ParseJSONTree) isLegalData() bool {
|
||||
|
Reference in New Issue
Block a user