LocateJSONPathInYAML finds the line/column position of a JSON path in YAML source
(yamlContent string, jsonPath string)
| 70 | |
| 71 | // LocateJSONPathInYAML finds the line/column position of a JSON path in YAML source |
| 72 | func LocateJSONPathInYAML(yamlContent string, jsonPath string) JSONPathLocation { |
| 73 | jsonPathLog.Printf("Locating JSON path in YAML: %s", jsonPath) |
| 74 | |
| 75 | if jsonPath == "" { |
| 76 | // Root level error - return start of content |
| 77 | return JSONPathLocation{Line: 1, Column: 1, Found: true} |
| 78 | } |
| 79 | |
| 80 | // Parse the path segments |
| 81 | pathSegments := parseJSONPath(jsonPath) |
| 82 | if len(pathSegments) == 0 { |
| 83 | return JSONPathLocation{Line: 1, Column: 1, Found: true} |
| 84 | } |
| 85 | |
| 86 | jsonPathLog.Printf("Parsed %d path segments", len(pathSegments)) |
| 87 | |
| 88 | // Use a more sophisticated line-by-line approach to find the path |
| 89 | location := findPathInYAMLLines(yamlContent, pathSegments) |
| 90 | jsonPathLog.Printf("Location result: line=%d, column=%d, found=%v", location.Line, location.Column, location.Found) |
| 91 | return location |
| 92 | } |
| 93 | |
| 94 | // LocateJSONPathForPathInfo finds the line/column position in YAML source for a JSONPathInfo. |
| 95 | // It uses ErrorKind for structural property-name extraction when available, and falls back to |