README
¶
Transcribe for Go
Go programs often need to output data in a structured representation format, such as JSON or YAML. But why not provide wider compatibility and support all common formats, letting the user choose? This library provides a unified API over several formats.
It also supports "pretty" printing to terminals with semantic colorization, including on Windows terminals, which defy common standards.
Binary formats (CBOR, MessagePack) can be output as is (incompatible with terminals) or textualized into Base64.
Supported formats:
- YAML
- JSON, including a convention for extending JSON to support additional types
- XML via a conventional schema
- CBOR
- MessagePack
Documentation
¶
Index ¶
- Constants
- Variables
- func ColorizeYAML(code string, writer io.Writer) error
- func DumpYAMLNode(writer io.Writer, node *yaml.Node, indent int)
- func DumpYAMLNodes(writer io.Writer, node *yaml.Node)
- func NewJSONColorFormatter(indent int) *prettyjson.Formatter
- func NewUtterConfig(indent string) *utter.ConfigState
- func OpenFileForWrite(path string) (*os.File, error)
- func Print(value any, format string, writer io.Writer, strict bool, pretty bool, ...) error
- func PrintCBOR(value any, writer io.Writer, base64 bool) error
- func PrintGo(value any, writer io.Writer, pretty bool) error
- func PrintJSON(value any, writer io.Writer, pretty bool) error
- func PrintMessagePack(value any, writer io.Writer, base64 bool) error
- func PrintXJSON(value any, writer io.Writer, pretty bool, reflector *ard.Reflector) error
- func PrintXML(value any, writer io.Writer, pretty bool, reflector *ard.Reflector) error
- func PrintXMLDocument(xmlDocument *etree.Document, writer io.Writer, pretty bool) error
- func PrintYAML(value any, writer io.Writer, strict bool, pretty bool, ...) error
- func Stringify(value any, format string, indent string, strict bool, reflector *ard.Reflector) (string, error)
- func StringifyCBOR(value any) (string, error)
- func StringifyGo(value any, indent string) (string, error)
- func StringifyJSON(value any, indent string) (string, error)
- func StringifyMessagePack(value any) (string, error)
- func StringifyXJSON(value any, indent string, reflector *ard.Reflector) (string, error)
- func StringifyXML(value any, indent string, reflector *ard.Reflector) (string, error)
- func StringifyYAML(value any, indent string, strict bool, reflector *ard.Reflector) (string, error)
- func Validate(code string, format string) error
- func ValidateCBOR(code string) error
- func ValidateJSON(code string) error
- func ValidateMessagePack(code string) error
- func ValidateXML(code string) error
- func ValidateYAML(code string) error
- func Write(value any, format string, indent string, strict bool, writer io.Writer, ...) error
- func WriteCBOR(value any, writer io.Writer, base64 bool) error
- func WriteGo(value any, writer io.Writer, indent string) error
- func WriteJSON(value any, writer io.Writer, indent string) error
- func WriteMessagePack(value any, writer io.Writer, base64 bool) error
- func WriteOrPrint(value any, format string, writer io.Writer, strict bool, pretty bool, ...) error
- func WriteXJSON(value any, writer io.Writer, indent string, reflector *ard.Reflector) error
- func WriteXML(value any, writer io.Writer, indent string, reflector *ard.Reflector) error
- func WriteXMLDocument(xmlDocument *etree.Document, writer io.Writer, indent string) error
- func WriteYAML(value any, writer io.Writer, indent string, strict bool, ...) error
Constants ¶
View Source
const DIRECTORY_WRITE_PERMISSIONS = 0700
View Source
const FILE_WRITE_PERMISSIONS = 0600
Variables ¶
View Source
var YAMLNodeKinds = map[yaml.Kind]string{
yaml.DocumentNode: "Document",
yaml.SequenceNode: "Sequence",
yaml.MappingNode: "Mapping",
yaml.ScalarNode: "Scalar",
yaml.AliasNode: "Alias",
}
Functions ¶
func DumpYAMLNode ¶
func DumpYAMLNodes ¶
func NewJSONColorFormatter ¶
func NewJSONColorFormatter(indent int) *prettyjson.Formatter
func NewUtterConfig ¶
func NewUtterConfig(indent string) *utter.ConfigState
func PrintXJSON ¶
func PrintXMLDocument ¶
func StringifyXJSON ¶
func StringifyXML ¶
func StringifyYAML ¶
func ValidateCBOR ¶
func ValidateJSON ¶
func ValidateMessagePack ¶
func ValidateXML ¶
func ValidateYAML ¶
func WriteOrPrint ¶
func WriteXJSON ¶
func WriteXMLDocument ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.