Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeCompatibleJSONBytes(code StringMap) ([]byte, bool)
- func DecodeCompatibleJSONInteger(code StringMap) (int64, bool)
- func DecodeCompatibleJSONUInteger(code StringMap) (uint64, bool)
- func Equals(a Value, b Value) bool
- func FindYAMLNode(node *yaml.Node, path ...PathElement) *yaml.Node
- 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 MergeMaps(target Map, source Map, mergeLists bool)
- func MergeStringMaps(target StringMap, source StringMap, mergeLists bool)
- func Read(reader io.Reader, format string, locate bool) (Map, Locator, error)
- func ReadCompatibleJSON(reader io.Reader, locate bool) (Map, Locator, error)
- func ReadJSON(reader io.Reader, locate bool) (Map, Locator, error)
- func ReadYAML(reader io.Reader, locate bool) (Map, Locator, error)
- func StringMapPutNested(map_ StringMap, key string, value string) error
- func ToYAMLDocumentNode(value Value, verbose bool) *yaml.Node
- func ToYAMLNode(value Value, verbose bool) *yaml.Node
- func ValueToString(data Value) string
- type CompatibleJSONBytes
- type CompatibleJSONInteger
- type CompatibleJSONMap
- type CompatibleJSONMapEntry
- type CompatibleJSONUInteger
- 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) 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 Copy(value Value) Value
- func FromCompatibleJSON(value Value) Value
- func ToCompatibleJSON(value Value) Value
- func ToMaps(value Value) (Value, bool)
- func ToStringMaps(value Value) (Value, bool)
- func TryFromCompatibleJSON(value Value) (Value, bool)
- func TryToCompatibleJSON(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 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 DecodeCompatibleJSONBytes ¶ added in v0.1.15
func DecodeCompatibleJSONInteger ¶ added in v0.1.15
func DecodeCompatibleJSONUInteger ¶ added in v0.1.15
func FindYAMLNode ¶
func FindYAMLNode(node *yaml.Node, path ...PathElement) *yaml.Node
func MergeStringMaps ¶
func ReadCompatibleJSON ¶ added in v0.1.16
func StringMapPutNested ¶
TODO: use Node instead
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 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 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 FromCompatibleJSON ¶ added in v0.1.15
func ToCompatibleJSON ¶ added in v0.1.15
func ToStringMaps ¶
func TryFromCompatibleJSON ¶ added in v0.1.15
func TryToCompatibleJSON ¶ added in v0.1.15
type YAMLLocator ¶
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.