translate

package
v0.319.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesXMLFromArrai added in v0.238.0

func BytesXMLFromArrai(v rel.Value) (rel.Value, error)

BytesXMLFromArrai converts an Arr.ai object to an XML document in byte resentation

func BytesXMLToArrai added in v0.238.0

func BytesXMLToArrai(bs []byte, config XMLDecodeConfig) (rel.Value, error)

BytesXMLToArrai converts a well formatted XML document in byte representation to a structured Arr.ai object

Types

type Translator added in v0.276.0

type Translator struct {
	// contains filtered or unexported fields
}

func NewTranslator added in v0.276.0

func NewTranslator(strict bool) Translator

func StrictTranslator added in v0.276.0

func StrictTranslator() Translator

func (Translator) BytesYamlToArrai added in v0.276.0

func (t Translator) BytesYamlToArrai(bytes []byte) (rel.Value, error)

func (Translator) FromArrai added in v0.276.0

func (t Translator) FromArrai(v rel.Value) (interface{}, error)

FromArrai translates an arrai value to an object suitable for marshalling into json/yaml.

FromArrai translation rules is the reverse of ToArrai.

func (Translator) ToArrai added in v0.276.0

func (t Translator) ToArrai(data interface{}) (rel.Value, error)

ToArrai translates an object unmarshalled from json/yaml into an arrai value.

translation follows the rules

object -> {|@,@item|, |key,val|, ...}
array  -> array
null   -> none
other  -> value (bools, numerics, strings)

type XMLDecodeConfig added in v0.238.0

type XMLDecodeConfig struct {
	TrimSurroundingWhitespace bool
}

NOTE: Currently the XML transform does not support documents with explicit namespaces. NOTE: A full cycle from XML -> Arr.ai -> XML reproduces semantically similar documents with possibly different content.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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