MCPcopy Create free account
hub / github.com/astercloud/aster / extractJSON

Function extractJSON

pkg/executionplan/generator.go:337–347  ·  view source on GitHub ↗

extractJSON 从文本中提取 JSON 部分

(text string)

Source from the content-addressed store, hash-verified

335
336// extractJSON 从文本中提取 JSON 部分
337func extractJSON(text string) (string, error) {
338 // 查找第一个 { 和最后一个 }
339 start := strings.Index(text, "{")
340 end := strings.LastIndex(text, "}")
341
342 if start == -1 || end == -1 || end <= start {
343 return "", errors.New("no valid JSON object found in text")
344 }
345
346 return text[start : end+1], nil
347}
348
349// FormatPlan 格式化执行计划为可读文本
350func FormatPlan(plan *ExecutionPlan) string {

Callers 1

parseResponseMethod · 0.70

Calls 1

IndexMethod · 0.80

Tested by

no test coverage detected