Documentation
¶
Index ¶
- func Load(p Parser, reader io.Reader) (interface{}, error)
- func LoadFromFile(filename string, p Parser) (interface{}, error)
- func Write(p Parser, value interface{}, originalValue interface{}, writer io.Writer) error
- type CSVDocument
- type CSVParser
- type JSONParser
- type OriginalRequired
- type Parser
- type RealValue
- type TOMLParser
- type UnknownParserErr
- type XMLParser
- type YAMLMultiDocument
- type YAMLParser
- type YAMLSingleDocument
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFromFile ¶
LoadFromFile loads data from the given file.
Types ¶
type CSVDocument ¶ added in v1.3.0
type CSVDocument struct {
Value []map[string]interface{}
Headers []string
// contains filtered or unexported fields
}
CSVDocument represents a CSV file. This is required to keep headers in the expected order.
func (CSVDocument) OriginalRequired ¶ added in v1.3.0
func (d CSVDocument) OriginalRequired() bool
OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
func (*CSVDocument) RealValue ¶ added in v1.3.0
func (d *CSVDocument) RealValue() interface{}
RealValue returns the real value that dasel should use when processing data.
type CSVParser ¶ added in v1.3.0
type CSVParser struct {
}
CSVParser is a Parser implementation to handle yaml files.
type JSONParser ¶
type JSONParser struct {
}
JSONParser is a Parser implementation to handle yaml files.
func (*JSONParser) FromBytes ¶
func (p *JSONParser) FromBytes(byteData []byte) (interface{}, error)
FromBytes returns some Data that is represented by the given bytes.
func (*JSONParser) ToBytes ¶
func (p *JSONParser) ToBytes(value interface{}) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.
type OriginalRequired ¶ added in v1.2.0
type OriginalRequired interface {
// OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
OriginalRequired() bool
}
OriginalRequired can be used in conjunction with RealValue to allow parsers to be more intelligent with the data they read/write.
type Parser ¶
type Parser interface {
// FromBytes returns some Data that is represented by the given bytes.
FromBytes(byteData []byte) (interface{}, error)
// ToBytes returns a slice of bytes that represents the given value.
ToBytes(value interface{}) ([]byte, error)
}
Parser can be used to load and save files from/to disk.
func NewParserFromFilename ¶
NewParserFromFilename returns a Parser from the given filename.
func NewParserFromString ¶
NewParserFromString returns a Parser from the given parser name.
type RealValue ¶ added in v1.2.0
type RealValue interface {
// RealValue returns the real value that dasel should use when processing data.
RealValue() interface{}
}
RealValue can be used in conjunction with OriginalRequired to allow parsers to be more intelligent with the data they read/write.
type TOMLParser ¶ added in v0.0.5
type TOMLParser struct {
}
TOMLParser is a Parser implementation to handle yaml files.
func (*TOMLParser) FromBytes ¶ added in v0.0.5
func (p *TOMLParser) FromBytes(byteData []byte) (interface{}, error)
FromBytes returns some Data that is represented by the given bytes.
func (*TOMLParser) ToBytes ¶ added in v0.0.5
func (p *TOMLParser) ToBytes(value interface{}) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.
type UnknownParserErr ¶
type UnknownParserErr struct {
Parser string
}
UnknownParserErr is returned when an invalid parser name is given.
func (UnknownParserErr) Error ¶
func (e UnknownParserErr) Error() string
Error returns the error message.
type XMLParser ¶ added in v1.0.1
type XMLParser struct {
}
XMLParser is a Parser implementation to handle yaml files.
type YAMLMultiDocument ¶ added in v1.2.0
type YAMLMultiDocument struct {
Values []interface{}
// contains filtered or unexported fields
}
YAMLMultiDocument represents a decoded multi-document YAML file.
func (YAMLMultiDocument) OriginalRequired ¶ added in v1.2.0
func (d YAMLMultiDocument) OriginalRequired() bool
OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
func (*YAMLMultiDocument) RealValue ¶ added in v1.2.0
func (d *YAMLMultiDocument) RealValue() interface{}
RealValue returns the real value that dasel should use when processing data.
type YAMLParser ¶
type YAMLParser struct {
}
YAMLParser is a Parser implementation to handle yaml files.
func (*YAMLParser) FromBytes ¶
func (p *YAMLParser) FromBytes(byteData []byte) (interface{}, error)
FromBytes returns some Data that is represented by the given bytes.
func (*YAMLParser) ToBytes ¶
func (p *YAMLParser) ToBytes(value interface{}) ([]byte, error)
ToBytes returns a slice of bytes that represents the given value.
type YAMLSingleDocument ¶ added in v1.2.0
type YAMLSingleDocument struct {
Value interface{}
// contains filtered or unexported fields
}
YAMLSingleDocument represents a decoded single-document YAML file.
func (YAMLSingleDocument) OriginalRequired ¶ added in v1.2.0
func (d YAMLSingleDocument) OriginalRequired() bool
OriginalRequired tells dasel if the parser requires the original value when converting to bytes.
func (*YAMLSingleDocument) RealValue ¶ added in v1.2.0
func (d *YAMLSingleDocument) RealValue() interface{}
RealValue returns the real value that dasel should use when processing data.