in cli/models/catalog.go [170:194]
func resultsBackToJson(wr io.Writer, values []reflect.Value, raw bool) error {
for i, r := range values {
object := r.Interface()
jsonText, err := json.Marshal(object)
if err != nil {
return fmt.Errorf("error converting object to JSON: %s", err)
}
if r.Kind() == reflect.String && raw {
stringWithQuotes := string(jsonText)
trimLeft := strings.TrimPrefix(stringWithQuotes, `"`)
withoutQuotes := strings.TrimSuffix(trimLeft, `"`)
jsonText = []byte(withoutQuotes)
}
if i != len(values)-1 {
jsonText = append(jsonText, ' ')
}
if _, err := wr.Write(jsonText); err != nil {
return err
}
}
return nil
}