解决类型反射NPE问题

This commit is contained in:
2022-01-27 14:23:41 +08:00
parent 19813fa9ee
commit 51808626a9
2 changed files with 6 additions and 3 deletions

View File

@ -129,7 +129,11 @@ func (df *DataFilter) UserItemToSlice() {
//
// Date : 2022/1/23 12:45 AM
func (df *DataFilter) getValueType(valueResult gjson.Result) string {
dataType := reflect.TypeOf(valueResult.Value()).String()
dataTypeVal := reflect.TypeOf(valueResult.Value())
if nil == dataTypeVal {
return "NIL"
}
dataType := dataTypeVal.String()
if strings.Contains(dataType, "int") {
return "int64"
}
@ -243,7 +247,6 @@ func (df *DataFilter) getArrayData(source string, pathArr []string) []gjson.Resu
resultList := make([]gjson.Result, 0)
dataList := gjson.Get(source, pathArr[0]).Array()
for idx := 0; idx < len(dataList); idx++ {
// sourceData := gjson.Get(source, dataList[idx].String()).String()
resultList = append(resultList, df.getArrayData(dataList[idx].String(), pathArr[1:])...)
}
return resultList