(results []any)
| 123 | } |
| 124 | |
| 125 | func 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 | |
| 145 | func valFromJqPath(path string, jsn string) (any, error) { |
| 146 | vals, err := valsFromJqPath(path, jsn) |
no outgoing calls