Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(code string, format string, locate bool) (Value, Locator, error)
- func DecodeCBOR(code string) (Value, Locator, error)
- func DecodeCompatibleJSON(code string, locate bool) (Value, Locator, error)
- func DecodeCompatibleJSONBytes(code StringMap) ([]byte, bool)
- func DecodeCompatibleJSONInteger(code StringMap) (int64, bool)
- func DecodeCompatibleJSONUInteger(code StringMap) (uint64, bool)
- func DecodeCompatibleXML(code string, locate bool) (Value, Locator, error)
- func DecodeJSON(code string, locate bool) (Value, Locator, error)
- func DecodeMessagePack(code string) (Value, Locator, error)
- func DecodeYAML(code string, locate bool) (Value, Locator, error)
- func Equals(a Value, b Value) bool
- func FindYAMLNode(node *yaml.Node, path ...PathElement) *yaml.Node
- func FromCompatibleXML(element *etree.Element) (any, error)
- func IsBoolean(value Value) bool
- func IsBytes(value Value) bool
- func IsFloat(value Value) bool
- func IsInteger(value Value) bool
- func IsList(value Value) bool
- func IsMap(value Value) bool
- func IsNull(value Value) bool
- func IsPrimitiveType(value Value) bool
- func IsString(value Value) bool
- func IsTimestamp(value Value) bool
- func MergeMaps(target Map, source Map, mergeLists bool)
- func MergeStringMaps(target StringMap, source StringMap, mergeLists bool)
- func Read(reader io.Reader, format string, locate bool) (Value, Locator, error)
- func ReadCBOR(reader io.Reader) (Value, Locator, error)
- func ReadCompatibleJSON(reader io.Reader, locate bool) (Value, Locator, error)
- func ReadCompatibleXML(reader io.Reader, locate bool) (Value, Locator, error)
- func ReadJSON(reader io.Reader, locate bool) (Value, Locator, error)
- func ReadMessagePack(reader io.Reader) (Value, Locator, error)
- func ReadYAML(reader io.Reader, locate bool) (Value, Locator, error)
- func StringMapPutNested(map_ StringMap, key string, value string) error
- func ToCompatibleXML(value any) any
- func ToFloat64(value Value) float64
- func ToInt64(value Value) int64
- func ToUInt64(value Value) uint64
- func ToYAMLDocumentNode(value Value, verbose bool) (*yaml.Node, error)
- func ToYAMLNode(value Value, verbose bool) (*yaml.Node, bool)
- func ValueToString(value Value) string
- type CompatibleJSONBytes
- type CompatibleJSONInteger
- type CompatibleJSONMap
- type CompatibleJSONMapEntry
- type CompatibleJSONUInteger
- type CompatibleXMLBytes
- type CompatibleXMLList
- type CompatibleXMLMap
- type CompatibleXMLMapEntry
- type CompatibleXMLNil
- type FromARD
- type List
- type Locator
- type Map
- type Node
- func (self *Node) Append(value Value) bool
- func (self *Node) Boolean() (bool, bool)
- func (self *Node) Bytes() ([]byte, bool)
- func (self *Node) ConvertSimilar() *Node
- func (self *Node) EnsureMap(keys ...string) (Map, bool)
- func (self *Node) Float() (float64, bool)
- func (self *Node) Get(keys ...string) *Node
- func (self *Node) Integer() (int64, bool)
- func (self *Node) List() (List, bool)
- func (self *Node) Map() (Map, bool)
- func (self *Node) NilMeansZero() *Node
- func (self *Node) Put(key string, value Value) bool
- func (self *Node) String() (string, bool)
- func (self *Node) StringList() ([]string, bool)
- func (self *Node) StringMap() (StringMap, bool)
- func (self *Node) UnsignedInteger() (uint64, bool)
- type Path
- type PathElement
- type PathElementType
- type ReflectField
- type ReflectFields
- type Reflector
- func (self *Reflector) NewReflectFields(type_ reflect.Type) ReflectFields
- func (self *Reflector) Pack(value Value, packedValuePtr any) error
- func (self *Reflector) PackReflect(value Value, packedValue reflect.Value) error
- func (self *Reflector) Unpack(packedValue any) (Value, error)
- func (self *Reflector) UnpackReflect(packedValue reflect.Value) (Value, error)
- type StringMap
- type StructFieldNameMapperFunc
- type ToARD
- type TypeName
- type TypeValidator
- type Value
- func Canonicalize(value Value) (Value, error)
- func CopyToARD(value Value) (Value, error)
- func DecodeYAMLTemplate(code string, data any) (Value, error)
- func EnsureCompatibleJSON(value Value) (Value, error)
- func EnsureCompatibleXML(value Value) (Value, error)
- func FromCompatibleJSON(value Value) (Value, bool)
- func NormalizeMaps(value Value) (Value, bool)
- func NormalizeMapsCopyToARD(value Value) (Value, error)
- func NormalizeMapsSimpleCopy(value Value) Value
- func NormalizeStringMaps(value Value) (Value, bool)
- func NormalizeStringMapsCopyToARD(value Value) (Value, error)
- func NormalizeStringMapsSimpleCopy(value Value) Value
- func Roundtrip(value Value, format string) (Value, error)
- func RoundtripCBOR(value Value) (Value, error)
- func RoundtripCompatibleJSON(value Value) (Value, error)
- func RoundtripCompatibleXML(value Value) (Value, error)
- func RoundtripJSON(value Value) (Value, error)
- func RoundtripMessagePack(value Value) (Value, error)
- func RoundtripYAML(value Value) (Value, error)
- func SimpleCopy(value Value) Value
- func ToCompatibleJSON(value Value) (Value, bool)
- type YAMLLocator
Constants ¶
View Source
const ( CompatibleJSONIntegerCode = "$ard.integer" CompatibleJSONUIntegerCode = "$ard.uinteger" CompatibleJSONBytesCode = "$ard.bytes" CompatibleJSONMapCode = "$ard.map" )
View Source
const ( FieldPathType = iota MapPathType ListPathType SequencedListPathType )
View Source
const ( CompatibleXMLNilTag = "nil" CompatibleXMLBytesTag = "bytes" CompatibleXMLListTag = "list" CompatibleXMLMapTag = "map" CompatibleXMLMapEntryTag = "entry" CompatibleXMLMapEntryKeyTag = "key" CompatibleXMLMapEntryValueTag = "value" )
Variables ¶
View Source
var TypeValidators = map[TypeName]TypeValidator{ TypeMap: IsMap, TypeList: IsList, TypeString: IsString, TypeBoolean: IsBoolean, TypeInteger: IsInteger, TypeFloat: IsFloat, TypeNull: IsNull, TypeBytes: IsBytes, TypeTimestamp: IsTimestamp, }
View Source
var TypeZeroes = map[TypeName]Value{ TypeMap: make(Map), TypeList: List{}, TypeString: "", TypeBoolean: false, TypeInteger: int(0), TypeFloat: float64(0.0), TypeNull: nil, TypeBytes: []byte{}, TypeTimestamp: time.Time{}, }
Functions ¶
func DecodeCBOR ¶ added in v0.1.20
The code should be in Base64
func DecodeCompatibleJSON ¶ added in v0.1.19
func DecodeCompatibleJSONBytes ¶ added in v0.1.15
func DecodeCompatibleJSONInteger ¶ added in v0.1.15
func DecodeCompatibleJSONUInteger ¶ added in v0.1.15
func DecodeCompatibleXML ¶ added in v0.1.19
func DecodeJSON ¶ added in v0.1.19
func DecodeMessagePack ¶ added in v0.1.62
The code should be in Base64
func DecodeYAML ¶ added in v0.1.19
func FindYAMLNode ¶
func FindYAMLNode(node *yaml.Node, path ...PathElement) *yaml.Node
func FromCompatibleXML ¶ added in v0.1.18
func IsPrimitiveType ¶ added in v0.1.60
func MergeStringMaps ¶
func ReadCompatibleJSON ¶ added in v0.1.16
func ReadCompatibleXML ¶ added in v0.1.18
func ReadMessagePack ¶ added in v0.1.62
func StringMapPutNested ¶
TODO: use Node instead
func ToCompatibleXML ¶ added in v0.1.18
func ToYAMLDocumentNode ¶
func ToYAMLNode ¶
func ValueToString ¶
Types ¶
type CompatibleJSONBytes ¶ added in v0.1.15
type CompatibleJSONBytes []byte
func (CompatibleJSONBytes) MarshalJSON ¶ added in v0.1.15
func (self CompatibleJSONBytes) MarshalJSON() ([]byte, error)
json.Marshaler interface
type CompatibleJSONInteger ¶ added in v0.1.15
type CompatibleJSONInteger int64
func (CompatibleJSONInteger) MarshalJSON ¶ added in v0.1.15
func (self CompatibleJSONInteger) MarshalJSON() ([]byte, error)
json.Marshaler interface
type CompatibleJSONMap ¶ added in v0.1.15
type CompatibleJSONMap Map
func (CompatibleJSONMap) MarshalJSON ¶ added in v0.1.15
func (self CompatibleJSONMap) MarshalJSON() ([]byte, error)
json.Marshaler interface
type CompatibleJSONMapEntry ¶ added in v0.1.15
func DecodeCompatibleJSONMapEntry ¶ added in v0.1.15
func DecodeCompatibleJSONMapEntry(entry Value) (*CompatibleJSONMapEntry, bool)
type CompatibleJSONUInteger ¶ added in v0.1.15
type CompatibleJSONUInteger uint64
func (CompatibleJSONUInteger) MarshalJSON ¶ added in v0.1.15
func (self CompatibleJSONUInteger) MarshalJSON() ([]byte, error)
json.Marshaler interface
type CompatibleXMLBytes ¶ added in v0.1.62
type CompatibleXMLBytes struct {
// contains filtered or unexported fields
}
func (CompatibleXMLBytes) MarshalXML ¶ added in v0.1.62
func (self CompatibleXMLBytes) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error
xml.Marshaler interface
type CompatibleXMLList ¶ added in v0.1.18
type CompatibleXMLList struct {
Entries []any
}
func (CompatibleXMLList) MarshalXML ¶ added in v0.1.18
func (self CompatibleXMLList) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error
xml.Marshaler interface
type CompatibleXMLMap ¶ added in v0.1.18
type CompatibleXMLMap struct {
// contains filtered or unexported fields
}
func (CompatibleXMLMap) MarshalXML ¶ added in v0.1.18
func (self CompatibleXMLMap) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error
xml.Marshaler interface
type CompatibleXMLMapEntry ¶ added in v0.1.18
type CompatibleXMLMapEntry struct {
// contains filtered or unexported fields
}
func NewCompatibleXMLMapEntry ¶ added in v0.1.20
func NewCompatibleXMLMapEntry(element *etree.Element) (CompatibleXMLMapEntry, error)
func (CompatibleXMLMapEntry) MarshalXML ¶ added in v0.1.18
func (self CompatibleXMLMapEntry) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error
xml.Marshaler interface
type CompatibleXMLNil ¶ added in v0.1.62
type CompatibleXMLNil struct{}
func (CompatibleXMLNil) MarshalXML ¶ added in v0.1.62
func (self CompatibleXMLNil) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error
xml.Marshaler interface
type Map ¶
func DecodeCompatibleJSONMap ¶ added in v0.1.15
type Node ¶
type Node struct { Value Value // contains filtered or unexported fields }
func (*Node) ConvertSimilar ¶ added in v0.1.61
func (*Node) NilMeansZero ¶ added in v0.1.61
func (*Node) StringList ¶ added in v0.1.30
func (*Node) UnsignedInteger ¶
Supports .ConvertSimilar()
type Path ¶
type Path []PathElement
func (Path) Append ¶
func (self Path) Append(element PathElement) Path
func (Path) AppendField ¶
func (Path) AppendList ¶
func (Path) AppendSequencedList ¶
type PathElement ¶
type PathElement struct { Type PathElementType Value any // string for FieldPathType and MapPathType, int for ListPathType and SequencedListPathType }
func NewFieldPathElement ¶
func NewFieldPathElement(name string) PathElement
func NewListPathElement ¶
func NewListPathElement(index int) PathElement
func NewMapPathElement ¶
func NewMapPathElement(name string) PathElement
func NewSequencedListPathElement ¶
func NewSequencedListPathElement(index int) PathElement
type PathElementType ¶
type PathElementType uint8
type ReflectField ¶ added in v0.1.62
type ReflectField struct {
// contains filtered or unexported fields
}
type ReflectFields ¶ added in v0.1.62
type ReflectFields map[string]ReflectField // ARD name
type Reflector ¶ added in v0.1.61
type Reflector struct { IgnoreMissingStructFields bool NilMeansZero bool StructFieldTags []string // in order StructFieldNameMapper StructFieldNameMapperFunc // contains filtered or unexported fields }
func NewReflector ¶ added in v0.1.61
func NewReflector() *Reflector
func (*Reflector) NewReflectFields ¶ added in v0.1.62
func (self *Reflector) NewReflectFields(type_ reflect.Type) ReflectFields
func (*Reflector) PackReflect ¶ added in v0.1.62
type StringMap ¶
func EnsureStringMaps ¶
Ensure data adheres to map[string]any (JSON encoding does not support map[any]any)
type StructFieldNameMapperFunc ¶ added in v0.1.61
type TypeName ¶
type TypeName string
const ( NoType TypeName = "" // Failsafe schema: https://yaml.org/spec/1.2/spec.html#id2802346 TypeMap TypeName = "ard.map" TypeList TypeName = "ard.list" TypeString TypeName = "ard.string" // JSON schema: https://yaml.org/spec/1.2/spec.html#id2803231 TypeBoolean TypeName = "ard.boolean" TypeInteger TypeName = "ard.integer" TypeFloat TypeName = "ard.float" // Other schemas: https://yaml.org/spec/1.2/spec.html#id2805770 TypeNull TypeName = "ard.null" TypeBytes TypeName = "ard.bytes" TypeTimestamp TypeName = "ard.timestamp" )
func GetTypeName ¶
type TypeValidator ¶
type Value ¶
type Value = any
func Canonicalize ¶ added in v0.1.21
func DecodeYAMLTemplate ¶ added in v0.1.19
func EnsureCompatibleJSON ¶ added in v0.1.21
func EnsureCompatibleXML ¶ added in v0.1.62
func FromCompatibleJSON ¶ added in v0.1.15
func NormalizeMaps ¶ added in v0.1.60
Ensure data adheres to the ARD map type (JSON decoding uses map[string]any instead of map[any]any)
func NormalizeMapsCopyToARD ¶ added in v0.1.61
func NormalizeMapsSimpleCopy ¶ added in v0.1.60
func NormalizeStringMaps ¶ added in v0.1.60
func NormalizeStringMapsCopyToARD ¶ added in v0.1.61
func NormalizeStringMapsSimpleCopy ¶ added in v0.1.60
func RoundtripCBOR ¶ added in v0.1.21
func RoundtripCompatibleJSON ¶ added in v0.1.21
func RoundtripCompatibleXML ¶ added in v0.1.62
func RoundtripJSON ¶ added in v0.1.62
func RoundtripMessagePack ¶ added in v0.1.62
func RoundtripYAML ¶ added in v0.1.21
func SimpleCopy ¶ added in v0.1.60
Will leave primitive and non-ARD types as is
func ToCompatibleJSON ¶ added in v0.1.15
type YAMLLocator ¶
type YAMLLocator struct {
RootNode *yaml.Node
}
func NewYAMLLocator ¶
func NewYAMLLocator(rootNode *yaml.Node) *YAMLLocator
func (*YAMLLocator) Locate ¶
func (self *YAMLLocator) Locate(path ...PathElement) (int, int, bool)
Locator interface
Click to show internal directories.
Click to hide internal directories.