Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(code string, format string, locate bool) (Value, Locator, error)
- func DecodeCBOR(code string, locate bool) (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 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) (interface{}, error)
- func IsBoolean(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 IsString(value Value) bool
- func IsTimestamp(value Value) bool
- func IsValid(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, locate bool) (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 ReadYAML(reader io.Reader, locate bool) (Value, Locator, error)
- func StringMapPutNested(map_ StringMap, key string, value string) error
- func ToCompatibleXML(data interface{}) interface{}
- func ToYAMLDocumentNode(value Value, verbose bool) *yaml.Node
- func ToYAMLNode(value Value, verbose bool) (*yaml.Node, bool)
- func ValueToString(data Value) string
- type CompatibleJSONBytes
- type CompatibleJSONInteger
- type CompatibleJSONMap
- type CompatibleJSONMapEntry
- type CompatibleJSONUInteger
- type CompatibleXMLList
- type CompatibleXMLMap
- type CompatibleXMLMapEntry
- type List
- type Locator
- type Map
- type Node
- func (self *Node) Append(value interface{}) bool
- func (self *Node) Boolean(allowNil bool) (bool, bool)
- func (self *Node) Float(allowNil bool) (float64, bool)
- func (self *Node) Get(key string) *Node
- func (self *Node) Integer(allowNil bool) (int64, bool)
- func (self *Node) List(allowNil bool) (List, bool)
- func (self *Node) Map(allowNil bool) (Map, bool)
- func (self *Node) Put(key string, value interface{}) bool
- func (self *Node) String(allowNil bool) (string, bool)
- func (self *Node) StringList(allowNil bool) ([]string, bool)
- func (self *Node) StringMap(allowNil bool) (StringMap, bool)
- func (self *Node) UnsignedInteger(allowNil bool) (uint64, bool)
- type Path
- type PathElement
- type PathElementType
- type StringMap
- type TypeName
- type TypeValidator
- type Value
- func Canonicalize(value Value) (Value, error)
- func Copy(value Value) Value
- func DecodeYAMLTemplate(code string, data interface{}) (Value, error)
- func EnsureCompatibleJSON(value Value) Value
- func FromCompatibleJSON(value Value) (Value, bool)
- func MapsToStringMaps(value Value) (Value, bool)
- func Normalize(value Value) (Value, bool)
- func RoundtripCBOR(value Value) (Value, error)
- func RoundtripCompatibleJSON(value Value) (Value, error)
- func RoundtripYAML(value Value) (Value, error)
- func ToCompatibleJSON(value Value) (Value, bool)
- type YAMLLocator
Constants ¶
View Source
const ( FieldPathType = iota MapPathType ListPathType SequencedListPathType )
Variables ¶
View Source
var CompatibleJSONBytesCode = "$ard.bytes"
View Source
var CompatibleJSONIntegerCode = "$ard.integer"
View Source
var CompatibleJSONMapCode = "$ard.map"
View Source
var CompatibleJSONUIntegerCode = "$ard.uinteger"
View Source
var CompatibleXMLListTag = "list"
View Source
var CompatibleXMLMapEntryKeyTag = "key"
View Source
var CompatibleXMLMapEntryTag = "entry"
View Source
var CompatibleXMLMapEntryValueTag = "value"
View Source
var CompatibleXMLMapTag = "map"
View Source
var NoNode = &Node{nil, nil, ""}
View Source
var TypeValidators = map[TypeName]TypeValidator{ TypeMap: IsMap, TypeList: IsList, TypeString: IsString, TypeBoolean: IsBoolean, TypeInteger: IsInteger, TypeFloat: IsFloat, TypeNull: IsNull, 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, 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 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 MergeStringMaps ¶
func ReadCompatibleJSON ¶ added in v0.1.16
func ReadCompatibleXML ¶ added in v0.1.18
func StringMapPutNested ¶
TODO: use Node instead
func ToCompatibleXML ¶ added in v0.1.18
func ToCompatibleXML(data interface{}) interface{}
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 CompatibleXMLList ¶ added in v0.1.18
type CompatibleXMLList struct {
Entries []interface{}
}
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 {
Entries []CompatibleXMLMapEntry
}
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 { Key interface{} Value interface{} }
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 Map ¶
func DecodeCompatibleJSONMap ¶ added in v0.1.15
type Node ¶
type Node struct { Data interface{} // contains filtered or unexported fields }
func (*Node) StringList ¶ added in v0.1.30
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 interface{} // 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 StringMap ¶
func EnsureStringMaps ¶
Ensure data adheres to map[string]interface{} (JSON encoding does not support map[interface{}]interface{})
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" TypeTimestamp TypeName = "ard.timestamp" )
func GetTypeName ¶
type TypeValidator ¶
type Value ¶
type Value = interface{}
func Canonicalize ¶ added in v0.1.21
func DecodeYAMLTemplate ¶ added in v0.1.19
func EnsureCompatibleJSON ¶ added in v0.1.21
func FromCompatibleJSON ¶ added in v0.1.15
func MapsToStringMaps ¶ added in v0.1.20
func Normalize ¶ added in v0.1.20
Ensure data adheres to the ARD map type (JSON decoding uses map[string]interface{} instead of map[interface{}]interface{})
func RoundtripCBOR ¶ added in v0.1.21
func RoundtripCompatibleJSON ¶ added in v0.1.21
func RoundtripYAML ¶ added in v0.1.21
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.