fix: Groovy脚本JSON解析加try-catch避免API返回格式异常时报错

This commit is contained in:
mediabot-pt
2026-07-01 12:19:55 +08:00
parent 217806a5de
commit a53ca06087

View File

@@ -6,7 +6,12 @@ final String API_BASE = "https://api.m-team.io"
Map parse(String content, String url) {
def slurp = new groovy.json.JsonSlurper()
def root = slurp.parseText(content)
def root
try {
root = slurp.parseText(content)
} catch (e) {
return [pageName: '解析失败', message: "JSON 解析异常: ${e.message}"]
}
if (url.contains('/api/member/profile'))
return parseProfile(root?.data)