修复数组未判断长度导致索引越界的BUG
This commit is contained in:
parent
7e464374bb
commit
d139b409fd
@ -106,6 +106,11 @@ func (oj *ownJson) generateStructField(rootPath string, currentName string, curr
|
|||||||
if currentResult.IsArray() {
|
if currentResult.IsArray() {
|
||||||
// 数组, 递归处理
|
// 数组, 递归处理
|
||||||
arrList := currentResult.Array()
|
arrList := currentResult.Array()
|
||||||
|
if len(arrList) == 0 {
|
||||||
|
// 空数组,无法判断类型,使用any
|
||||||
|
oj.structBuilder.AddField(structPath, "", []any{}, "", false)
|
||||||
|
return
|
||||||
|
}
|
||||||
if arrList[0].Type == gjson.True || arrList[0].Type == gjson.False {
|
if arrList[0].Type == gjson.True || arrList[0].Type == gjson.False {
|
||||||
oj.structBuilder.AddField(structPath, "", []bool{}, "", false)
|
oj.structBuilder.AddField(structPath, "", []bool{}, "", false)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user