|
|
|
@@ -183,3 +183,62 @@ func ExpandArrayPath(jsonStr string, pathConfig string, mapConfig string, expend
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsObject 判断是否是对象, 兼容序列化之后的对象
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 18:04 2024/12/1
|
|
|
|
|
func IsObject(gjsonResult gjson.Result) bool {
|
|
|
|
|
return gjsonResult.IsObject() || gjson.Parse(gjsonResult.String()).IsObject()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IsArray 判断是否为数组
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 18:05 2024/12/1
|
|
|
|
|
func IsArray(gjsonResult gjson.Result) bool {
|
|
|
|
|
return gjsonResult.IsArray() || gjson.Parse(gjsonResult.String()).IsArray()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Object 兼容序列化之后的对象
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 18:09 2024/12/1
|
|
|
|
|
func Object(gjsonResult gjson.Result) gjson.Result {
|
|
|
|
|
res := gjson.Parse(gjsonResult.String())
|
|
|
|
|
if res.IsObject() {
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
return gjsonResult
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Array ...
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 18:09 2024/12/1
|
|
|
|
|
func Array(gjsonResult gjson.Result) gjson.Result {
|
|
|
|
|
res := gjson.Parse(gjsonResult.String())
|
|
|
|
|
if res.IsArray() {
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
return gjsonResult
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Result ...
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 18:12 2024/12/1
|
|
|
|
|
func Result(gjsonResult gjson.Result) gjson.Result {
|
|
|
|
|
if IsObject(gjsonResult) {
|
|
|
|
|
return gjsonResult
|
|
|
|
|
}
|
|
|
|
|
if IsArray(gjsonResult) {
|
|
|
|
|
return Array(gjsonResult)
|
|
|
|
|
}
|
|
|
|
|
return gjsonResult
|
|
|
|
|
}
|