feat(): updating array to json

Signed-off-by: Art Begolli <artbegolli@gmail.com>
pull/6096/head^2
Art Begolli 6 years ago
parent 5b90613fc2
commit da891450b9

@ -59,6 +59,10 @@ type ResultEntry struct {
Description string `json:"description"` Description string `json:"description"`
} }
type Results struct {
SearchResults []ResultEntry `json:"searchResults"`
}
func newSearchCmd(out io.Writer) *cobra.Command { func newSearchCmd(out io.Writer) *cobra.Command {
sc := &searchCmd{out: out} sc := &searchCmd{out: out}
@ -171,7 +175,7 @@ func (s *searchCmd) formatSearchResultsJson(res []*search.Result, colWidth uint)
} }
resultJson = append(resultJson, resultRow) resultJson = append(resultJson, resultRow)
} }
json, err := json.MarshalIndent(resultJson, "", " ") json, err := json.MarshalIndent(Results{SearchResults: resultJson}, "", " ")
if err != nil { if err != nil {
return "", err return "", err
} }

Loading…
Cancel
Save