in cli/models/catalog.go [196:216]
func displayAsJson(w io.Writer, v interface{}, displayPath string, raw bool) error {
j := jsonpath.New("displayer")
j.AllowMissingKeys(true)
// wrap the path with k8s.io's conventional {} braces for convenience
err := j.Parse(fmt.Sprintf("{%s}", displayPath))
if err != nil {
return fmt.Errorf("could not parse JSONPath expression (%s)", err)
}
allResults, err := j.FindResults(v)
if err != nil {
return fmt.Errorf("error evaluating JSONPath expression: %s", err)
}
for ix := range allResults {
if err = resultsBackToJson(w, allResults[ix], raw); err != nil {
return fmt.Errorf("display error: %s", err)
}
}
return nil
}