MCPcopy Index your code
hub / github.com/bootdotdev/bootdev / formatJqResults

Function formatJqResults

checks/jq.go:125–143  ·  view source on GitHub ↗
(results []any)

Source from the content-addressed store, hash-verified

123}
124
125func formatJqResults(results []any) []string {
126 if len(results) == 0 {
127 return nil
128 }
129 formatted := make([]string, 0, len(results))
130 for _, result := range results {
131 if result == nil {
132 formatted = append(formatted, "null")
133 continue
134 }
135 encoded, err := json.Marshal(result)
136 if err != nil {
137 formatted = append(formatted, fmt.Sprintf("%v", result))
138 continue
139 }
140 formatted = append(formatted, string(encoded))
141 }
142 return formatted
143}
144
145func valFromJqPath(path string, jsn string) (any, error) {
146 vals, err := valsFromJqPath(path, jsn)

Callers 2

TestFormatJqResultsFunction · 0.85
runStdoutJqQueryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestFormatJqResultsFunction · 0.68