Documentation
¶
Overview ¶
Package format provides result formatters for gograph query output. It supports multiple output formats including JSON, XML, YAML, and CSV.
Basic Usage:
formatter := format.NewFormatter("json")
output, err := formatter.Format(result)
if err != nil {
log.Fatal(err)
}
fmt.Println(output)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSVFormatter ¶
type CSVFormatter struct{}
CSVFormatter formats results as CSV.
func (*CSVFormatter) ContentType ¶
func (f *CSVFormatter) ContentType() string
ContentType returns the MIME type for CSV.
type Formatter ¶
type Formatter interface {
// Format converts a cypher.Result into a formatted string.
Format(result cypher.Result) (string, error)
// ContentType returns the MIME type for this formatter.
ContentType() string
}
Formatter defines the interface for formatting query results.
func NewFormatter ¶
NewFormatter creates a formatter for the given format name. Supported formats: "json", "xml", "yaml", "csv", "table" (default).
Example:
formatter := format.NewFormatter("json")
output, err := formatter.Format(result)
type JSONFormatter ¶
type JSONFormatter struct{}
JSONFormatter formats results as JSON.
func (*JSONFormatter) ContentType ¶
func (f *JSONFormatter) ContentType() string
ContentType returns the MIME type for JSON.
type TableFormatter ¶
type TableFormatter struct{}
TableFormatter formats results as a human-readable table (default).
func (*TableFormatter) ContentType ¶
func (f *TableFormatter) ContentType() string
ContentType returns the MIME type for plain text.
type XMLFormatter ¶
type XMLFormatter struct{}
XMLFormatter formats results as XML.
func (*XMLFormatter) ContentType ¶
func (f *XMLFormatter) ContentType() string
ContentType returns the MIME type for XML.
type YAMLFormatter ¶
type YAMLFormatter struct{}
YAMLFormatter formats results as YAML-like text.
func (*YAMLFormatter) ContentType ¶
func (f *YAMLFormatter) ContentType() string
ContentType returns the MIME type for YAML.