formatter

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package formatter holds utilities for working with different data formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AwareFormatter

type AwareFormatter struct {
	JSONFormatter JSONFormatter
	YAMLFormatter YAMLFormatter
}

AwareFormatter is entity that has ability to deserialize data in JSON or YAML format

func NewAwareFormatter

func NewAwareFormatter(JSONFormatter JSONFormatter, YAMLFormatter YAMLFormatter) AwareFormatter

func (AwareFormatter) Deserialize

func (a AwareFormatter) Deserialize(data []byte, v any) error

Deserialize data in format of JSON or YAML on v

type Formatter added in v0.12.0

type Formatter interface {
	// Deserialize deserializes data on v
	Deserialize(data []byte, v any) error

	// Serialize serializes v
	Serialize(v any) ([]byte, error)
}

Formatter describes ability to serialize and deserialize data

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter is entity that has ability to work with JSON format

func NewJSONFormatter

func NewJSONFormatter() JSONFormatter

func (JSONFormatter) Deserialize

func (J JSONFormatter) Deserialize(data []byte, v any) error

Deserialize data in format of JSON on v

func (JSONFormatter) Serialize added in v0.12.0

func (J JSONFormatter) Serialize(v any) ([]byte, error)

Serialize serializes v into JSON format.

type XMLFormatter added in v0.13.0

type XMLFormatter struct{}

XMLFormatter is entity that has ability to work with XML format

func NewXMLFormatter added in v0.13.0

func NewXMLFormatter() XMLFormatter

func (XMLFormatter) Deserialize added in v0.13.0

func (X XMLFormatter) Deserialize(data []byte, v any) error

Deserialize data in format of XML on v.

func (XMLFormatter) Serialize added in v0.13.0

func (X XMLFormatter) Serialize(v any) ([]byte, error)

Serialize serializes v into XML format.

type YAMLFormatter

type YAMLFormatter struct{}

YAMLFormatter is entity that has ability to work with YAML format

func NewYAMLFormatter

func NewYAMLFormatter() YAMLFormatter

func (YAMLFormatter) Deserialize

func (Y YAMLFormatter) Deserialize(data []byte, v any) error

Deserialize data in format of YAML on v

func (YAMLFormatter) Serialize added in v0.12.0

func (y YAMLFormatter) Serialize(v any) ([]byte, error)

Serialize serializes v into YAML format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL