save code
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
package json_tool
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
@ -218,18 +219,21 @@ func (df *DataFilter) dealDiffArr(diffArr []string) {
|
||||
|
||||
// 没处理过, 开始处理
|
||||
jsonResultList := df.getArrayData(df.source, diffArr)
|
||||
fmt.Println(jsonResultList)
|
||||
if len(jsonResultList) == 0 {
|
||||
return
|
||||
}
|
||||
newDataList := gabs.New()
|
||||
newPath := util.GenRandomString("", 8)
|
||||
var result map[string]interface{}
|
||||
_ = json.Unmarshal([]byte(df.source), &result)
|
||||
JSONObject, _ := gabs.Consume(result)
|
||||
_, _ = JSONObject.ArrayP(newPath)
|
||||
for _, item := range jsonResultList {
|
||||
newDataList.ArrayAppend(item.String())
|
||||
if err := JSONObject.ArrayAppendP(item.Value(), newPath); nil != err {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
}
|
||||
JSONObject, _ := gabs.Consume(df.source)
|
||||
_, _ = JSONObject.SetP(newDataList.Data(), newPath)
|
||||
fmt.Println(123, JSONObject.String())
|
||||
|
||||
df.source = JSONObject.String()
|
||||
}
|
||||
|
||||
// getArrayData 获取数据
|
||||
|
Reference in New Issue
Block a user