You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: json.go
    path of file: ./repos/trivy/pkg/k8s/report
    
    the code of the file until where you have to start completion: package report

import (
	"encoding/json"
	"fmt"
	"io"

	"golang.org/x/xerrors"
)

type JSONWriter struct {
	Output io.Wri
    
func (jw JSONWriter) Write(report Report) error {
	var output []byte
	var err error

	switch jw.Report {
	case AllReport:
		output, err = json.MarshalIndent(report, "", "  ")
		if err != nil {
			return xerrors.Errorf("failed to write json: %w", err)
		}
	case SummaryReport:
		output, err = json.MarshalIndent(report.consolidate(), "", "  ")
		if err != nil {
			return xerrors.Errorf("failed to write json: %w", err)
		}
	default:
		return xerrors.Errorf(`report %q not supported. Use "summary" or "all"`, jw.Report)
	}
	if _, err = fmt.Fprintln(jw.Output, string(output)); err != nil {
		return xerrors.Errorf("failed to write json: %w", err)
	}

	return nil
}