From d139b409fd3d67c876644312b1c7b9d2f9ff398f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 29 Apr 2025 11:37:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E7=BB=84=E6=9C=AA?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=95=BF=E5=BA=A6=E5=AF=BC=E8=87=B4=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E8=B6=8A=E7=95=8C=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wrapper/json.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wrapper/json.go b/wrapper/json.go index edc0aa3..37b86f9 100644 --- a/wrapper/json.go +++ b/wrapper/json.go @@ -106,6 +106,11 @@ func (oj *ownJson) generateStructField(rootPath string, currentName string, curr if currentResult.IsArray() { // 数组, 递归处理 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 { oj.structBuilder.AddField(structPath, "", []bool{}, "", false) return