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

Method ExtractAndParse

pkg/structured/typed.go:79–91  ·  view source on GitHub ↗

ExtractAndParse 提取 JSON 并解析为通用 map

(ctx context.Context, text string)

Source from the content-addressed store, hash-verified

77
78// ExtractAndParse 提取 JSON 并解析为通用 map
79func (tp *TypedParser) ExtractAndParse(ctx context.Context, text string) (map[string]any, error) {
80 rawJSON, err := extractJSONSegment(text)
81 if err != nil {
82 return nil, fmt.Errorf("extract json: %w", err)
83 }
84
85 var result map[string]any
86 if err := json.Unmarshal([]byte(rawJSON), &result); err != nil {
87 return nil, fmt.Errorf("unmarshal json: %w", err)
88 }
89
90 return result, nil
91}
92
93// TypedOutputSpec 类型化输出规范
94type TypedOutputSpec struct {

Callers

nothing calls this directly

Calls 1

extractJSONSegmentFunction · 0.85

Tested by

no test coverage detected