|
@@ -125,7 +125,8 @@ func (s *parserService) ParseSDKOnlineHTMLTable(htmlContent string) ([]v1.SDKInf
|
|
|
case 8: // 系统
|
|
|
info.System = text
|
|
|
case 9: // 附加信息
|
|
|
- info.ExtraInfo = text
|
|
|
+ // 对于附加信息列,提取JSON内容
|
|
|
+ info.ExtraInfo = extractJSONFromExtraInfo(text)
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -137,3 +138,63 @@ func (s *parserService) ParseSDKOnlineHTMLTable(htmlContent string) ([]v1.SDKInf
|
|
|
|
|
|
return sdkInfos, nil
|
|
|
}
|
|
|
+
|
|
|
+// extractJSONFromExtraInfo 从附加信息字符串中提取JSON内容
|
|
|
+func extractJSONFromExtraInfo(text string) string {
|
|
|
+ text = strings.TrimSpace(text)
|
|
|
+
|
|
|
+ // 尝试直接解析
|
|
|
+ if result := tryParseJSON(text); result != "" {
|
|
|
+ return result
|
|
|
+ }
|
|
|
+
|
|
|
+ // 尝试解析JSON字符串(去掉外层引号)
|
|
|
+ if strings.HasPrefix(text, `"`) && strings.HasSuffix(text, `"`) {
|
|
|
+ var jsonContent string
|
|
|
+ if json.Unmarshal([]byte(text), &jsonContent) == nil {
|
|
|
+ if result := tryParseJSON(jsonContent); result != "" {
|
|
|
+ return result
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从复杂文本中提取JSON
|
|
|
+ return extractFromComplexText(text)
|
|
|
+}
|
|
|
+
|
|
|
+// 统一的JSON解析和格式化函数
|
|
|
+func tryParseJSON(text string) string {
|
|
|
+ var temp interface{}
|
|
|
+ if json.Unmarshal([]byte(text), &temp) == nil {
|
|
|
+ if formatted, err := json.Marshal(temp); err == nil {
|
|
|
+ return string(formatted)
|
|
|
+ }
|
|
|
+ return text
|
|
|
+ }
|
|
|
+ return ""
|
|
|
+}
|
|
|
+
|
|
|
+// 简化的复杂文本JSON提取
|
|
|
+func extractFromComplexText(text string) string {
|
|
|
+ // 找到最后一个完整的JSON对象
|
|
|
+ for end := strings.LastIndex(text, "}"); end != -1; end = strings.LastIndex(text[:end], "}") {
|
|
|
+ // 向前查找匹配的开始大括号
|
|
|
+ braceCount := 1
|
|
|
+ for start := end - 1; start >= 0; start-- {
|
|
|
+ switch text[start] {
|
|
|
+ case '}':
|
|
|
+ braceCount++
|
|
|
+ case '{':
|
|
|
+ braceCount--
|
|
|
+ if braceCount == 0 {
|
|
|
+ candidate := text[start : end+1]
|
|
|
+ if result := tryParseJSON(candidate); result != "" {
|
|
|
+ return result
|
|
|
+ }
|
|
|
+ break // 跳出内层循环,继续寻找下一个'}'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "查看"
|
|
|
+}
|