README
¶
Agnostic Raw Data (ARD) for Go
A library to work with non-schematic data and consume it from various standard formats.
What is ARD? See here. Some people gloss it as "JSON", but that's misleading and ultimately unhelpful because JSON is merely a representation format for the data, and a rather limited format at that (e.g. it does not preserve the distinction between integers and floats).
This library supports several representation formats for ARD:
- YAML
- JSON, including a convention for extending JSON to support all ARD types
- XML via a conventional schema
- CBOR
- MessagePack
It is also implemented in Python.
And check out the ardconv ARD conversion tool.
Features
Read ARD from any Go Reader
or decode from strings:
import (
"fmt"
"strings"
"github.com/tliron/go-ard"
)
var yamlRepresentation = `
first:
property1: Hello
property2: 1.2
property3:
- 1
- 2
- second:
property1: World
`
func main() {
if value, _, err := ard.Read(strings.NewReader(yamlRepresentation), "yaml", false); err == nil {
fmt.Printf("%v\n", value)
}
}
Some formats (notably YAML) support a Locator
interface for finding the line and column
for each data element, very useful for error messages:
var yamlRepresentation = `
first:
property1: Hello
property2: 1.2
property3: [ 1, 2 ]
`
func main() {
if _, locator, err := ard.Decode(yamlRepresentation, "yaml", true); err == nil {
if locator != nil {
if line, column, ok := locator.Locate(
ard.NewMapPathElement("first"),
ard.NewFieldPathElement("property3"),
ard.NewListPathElement(0),
); ok {
fmt.Printf("%d, %d\n", line, column) // 5, 16
}
}
}
}
Unmarshal ARD into Go structs:
var data = ard.Map{ // "ard.Map" is an alias for "map[any]any"
"FirstName": "Gordon",
"lastName": "Freeman",
"nicknames": ard.List{"Tigerbalm", "Stud Muffin"}, // "ard.List" is an alias for "[]any"
"children": ard.List{
ard.Map{
"FirstName": "Bilbo",
},
ard.StringMap{ // "ard.StringMap" is an alias for "map[string]any"
"FirstName": "Frodo",
},
nil,
},
}
type Person struct {
FirstName string // property name will be used as field name
LastName string `ard:"lastName"` // "ard" tags work like familiar "json" and "yaml" tags
Nicknames []string `yaml:"nicknames"` // actually, go-ard will fall back to "yaml" tags by default
Children []*Person `json:"children"` // ...and "json" tags, too
}
func main() {
reflector := ard.NewReflector() // configurable; see documentation
var p Person
if err := reflector.Pack(data, &p); err == nil {
fmt.Printf("%+v\n", p)
}
}
Copy, merge, and compare:
func main() {
data_ := ard.Copy(data).(ard.Map)
fmt.Printf("%t\n", ard.Equals(data, data_))
ard.MergeMaps(data, ard.Map{"role": "hero", "children": ard.List{"Gollum"}}, true)
fmt.Printf("%v\n", data)
}
Node-based path traversal:
var data = ard.Map{
"first": ard.Map{
"property1": "Hello",
"property2": ard.StringMap{
"second": ard.Map{
"property1": 1}}}}
func main() {
if p1, ok := ard.NewNode(data).Get("first", "property1").String(); ok {
fmt.Println(p1)
}
if p2, ok := ard.NewNode(data).Get("first", "property2", "second", "property1").ConvertSimilar().Float(); ok {
fmt.Printf("%f\n", p2)
}
}
By default go-ard reads maps into map[any]any
, but you can normalize for either map[any]any
or
map[string]map
(Go's built-in JSON encoder unfortunately requires the latter):
import "encoding/json"
var data = ard.Map{ // remember, these are "map[any]any"
"person": ard.Map{
"age": uint(120),
},
}
func main() {
if data_, ok := ard.CopyMapsToStringMaps(data); ok { // otherwise "encoding/json" won't be able to encode the "map[any]any"
json.NewEncoder(os.Stdout).Encode(data_)
}
}
Introducing the "xjson" (eXtended JSON) format that adds support for missing ARD types: integers, unsigned integers, and maps with non-string keys:
var data = ard.Map{
"person": ard.Map{
"age": uint(120),
},
}
func main() {
if data_, ok := ard.PrepareForEncodingXJSON(data); ok { // will conveniently also normalize to "map[string]any" for "encoding/json" to work
if j, err := json.Marshal(data_); err == nil {
fmt.Println(string(j)) // {"map":{"age":{"$ard.uinteger":"120"}}}
if data__, _, err := ard.Decode(j, "xjson", false); err == nil {
fmt.Printf("%v\n", data__)
}
}
}
}
Documentation
¶
Index ¶
- Constants
- Variables
- func Decode(code []byte, format string, locate bool) (Value, Locator, error)
- func DecodeYAML(code []byte, locate bool) (Value, Locator, error)
- func Equals(a Value, b Value) bool
- func FindYAMLNode(node *yaml.Node, path ...PathElement) *yaml.Node
- 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 MapKeyToString(key any) string
- func MarshalMessagePack(value any) ([]byte, error)
- func NewMessagePackDecoder(reader io.Reader) *msgpack.Decoder
- func NewMessagePackEncoder(writer io.Writer) *msgpack.Encoder
- func PackXJSON(value Value) (any, bool)
- func PackXML(value Value) any
- func PrepareForEncodingXJSON(value Value, reflector *Reflector) (any, error)
- func PrepareForEncodingXML(value Value, reflector *Reflector) (any, error)
- func Read(reader io.Reader, format string, locate bool) (Value, Locator, error)
- func ReadURL(context contextpkg.Context, url exturl.URL, fallbackFormat string, locate bool) (Value, Locator, error)
- func ReadYAML(reader io.Reader, locate bool) (Value, Locator, error)
- func ToFloat64(value Value) float64
- func ToInt64(value Value) int64
- func ToUInt64(value Value) uint64
- func ToYAMLDocumentNode(value Value, verbose bool, reflector *Reflector) (*yaml.Node, error)
- func ToYAMLNode(value Value, verbose bool) (*yaml.Node, bool)
- func UnmarshalMessagePack(data []byte, value any) error
- func UnpackXJSONBytes(code StringMap) ([]byte, bool)
- func UnpackXJSONInteger(code StringMap) (int64, bool)
- func UnpackXJSONUInteger(code StringMap) (uint64, bool)
- func Validate(code []byte, format string) error
- func ValidateCBOR(code []byte, base64 bool) error
- func ValidateJSON(code []byte) error
- func ValidateMessagePack(code []byte, base64 bool) error
- func ValidateXML(code []byte) error
- func ValidateYAML(code []byte) error
- func ValueToString(value Value) string
- 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) PutNested(keys []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, useStringMaps bool) (Value, error)
- func (self *Reflector) UnpackReflect(packedValue reflect.Value, useStringMaps bool) (Value, error)
- type StringMap
- type StructFieldNameMapperFunc
- type ToARD
- type TypeName
- type TypeValidator
- type Value
- func ConvertMapsToStringMaps(value Value) (Value, bool)
- func ConvertStringMapsToMaps(value Value) (Value, bool)
- func Copy(value Value) Value
- func CopyMapsToStringMaps(value Value) Value
- func CopyStringMapsToMaps(value Value) Value
- func DecodeCBOR(code []byte, base64 bool) (Value, error)
- func DecodeJSON(code []byte, useStringMaps bool) (Value, error)
- func DecodeMessagePack(code []byte, base64 bool, useStringMaps bool) (Value, error)
- func DecodeTemplate(code string, data any, format string) (Value, error)
- func DecodeXJSON(code []byte, useStringMaps bool) (Value, error)
- func DecodeXML(code []byte) (Value, error)
- func Merge(target Value, source Value, appendLists bool) Value
- func ReadCBOR(reader io.Reader, base64 bool) (Value, error)
- func ReadJSON(reader io.Reader, useStringMaps bool) (Value, error)
- func ReadMessagePack(reader io.Reader, base64 bool, useStringMaps bool) (Value, error)
- func ReadXJSON(reader io.Reader, useStringMaps bool) (Value, error)
- func ReadXML(reader io.Reader) (Value, error)
- func Roundtrip(value Value, format string, reflector *Reflector) (Value, error)
- func RoundtripCBOR(value Value) (Value, error)
- func RoundtripJSON(value Value) (Value, error)
- func RoundtripMessagePack(value Value) (Value, error)
- func RoundtripXJSON(value Value, reflector *Reflector) (Value, error)
- func RoundtripXML(value Value, reflector *Reflector) (Value, error)
- func RoundtripYAML(value Value) (Value, error)
- func UnpackXJSON(value any, useStringMaps bool) (Value, bool)
- func UnpackXML(element *etree.Element) (Value, error)
- func ValidCopy(value Value, reflector *Reflector) (Value, error)
- func ValidCopyMapsToStringMaps(value Value, reflector *Reflector) (Value, error)
- func ValidCopyStringMapsToMaps(value Value, reflector *Reflector) (Value, error)
- type XJSONBytes
- type XJSONInteger
- type XJSONMap
- type XJSONMapEntry
- type XJSONUInteger
- type XMLBytes
- type XMLList
- type XMLMap
- type XMLMapEntry
- type XMLNil
- type YAMLLocator
Constants ¶
const ( FieldPathType = iota MapPathType ListPathType SequencedListPathType )
const ( XJSONIntegerCode = "$ard.integer" XJSONUIntegerCode = "$ard.uinteger" XJSONBytesCode = "$ard.bytes" XJSONMapCode = "$ard.map" )
const ( XMLNilTag = "nil" XMLBytesTag = "bytes" XMLListTag = "list" XMLMapTag = "map" XMLMapEntryTag = "entry" XMLMapEntryKeyTag = "key" XMLMapEntryValueTag = "value" )
Variables ¶
var TypeValidators = map[TypeName]TypeValidator{ TypeMap: IsMap, TypeList: IsList, TypeString: IsString, TypeBoolean: IsBoolean, TypeInteger: IsInteger, TypeFloat: IsFloat, TypeNull: IsNull, TypeBytes: IsBytes, TypeTimestamp: IsTimestamp, }
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 Decode ¶
Decodes supported formats to ARD.
All resulting maps are guaranteed to be Map (and not StringMap).
Supported formats are "yaml", "json", "xjson", "xml", "cbor", and "messagepack".
func Equals ¶
Checks for deep equality between two ARD values.
Primitives are compared via the `=` operator.
Note that Map and StringMap are treated as unequal. To gloss over the difference in type, call CopyStringMapsToMaps on both values first.
func FindYAMLNode ¶
func FindYAMLNode(node *yaml.Node, path ...PathElement) *yaml.Node
func IsPrimitiveType ¶
func MapKeyToString ¶ added in v0.2.0
Provides consistent stringification of keys for ARD StringMap.
Used by functions such as ConvertMapsToStringMaps and CopyMapsToStringMaps.
func MarshalMessagePack ¶ added in v0.2.1
func NewMessagePackDecoder ¶ added in v0.2.1
func NewMessagePackEncoder ¶ added in v0.2.1
func PrepareForEncodingXJSON ¶ added in v0.2.0
func PrepareForEncodingXML ¶ added in v0.2.0
func Read ¶
Reads and decodes supported formats to ARD.
All resulting maps are guaranteed to be Map (and not StringMap).
When locate is true will also attempt to return a Locator for the value if possible, otherwise will return nil.
Supported formats are "yaml", "json", "xjson", "xml", "cbor", and "messagepack".
func ReadURL ¶ added in v0.1.1
func ReadURL(context contextpkg.Context, url exturl.URL, fallbackFormat string, locate bool) (Value, Locator, error)
Supported formats are "yaml", "json", "xjson", "xml", "cbor", and "messagepack".
func ReadYAML ¶
Reads YAML from an io.Reader and decodes it into an ARD Value. If more than one YAML document is present (i.e. separated by `---`) then only the first will be decoded with the remainder ignored.
When locate is true will also return a Locator for the value, otherwise will return nil.
Note that the YAML implementation uses the yamlkeys library, so that arbitrarily complex map keys are supported and decoded into ARD Map. If you need to manipulate these maps you should use the yamlkeys utility functions.
func ToYAMLDocumentNode ¶
func ToYAMLNode ¶
func UnmarshalMessagePack ¶ added in v0.2.1
func UnpackXJSONBytes ¶ added in v0.2.0
func UnpackXJSONInteger ¶ added in v0.2.0
func UnpackXJSONUInteger ¶ added in v0.2.0
func Validate ¶ added in v0.2.1
Validates that data is of a supported format. Returns nil if valid, otherwise it will be the validation error.
While you can use Read to validate data, this function is optimized to be more lightweight. On other hand, this function does not do any schema validation (for example for XML), so if this function returns no error it does not guarantee that Read would also not return an error.
func ValidateCBOR ¶ added in v0.2.1
func ValidateJSON ¶ added in v0.2.1
func ValidateMessagePack ¶ added in v0.2.1
func ValidateXML ¶ added in v0.2.1
func ValidateYAML ¶ added in v0.2.1
func ValueToString ¶
Provides consistent stringification of primitive ARD Value.
Non-ARD types will be converted via util.ToString.
Types ¶
type Map ¶
An alias used to signify a map of ARD Value in which the key is also a Value. Note that this type does not protect its users against using invalid keys. Keys must be both hashable comparable.
type Node ¶
type Node struct { Value Value // contains filtered or unexported fields }
func (*Node) Append ¶
Appends a value to a List. Returns false if failed (not a List).
Note that this function changes the container of this node, which is the one that actually holds the slice.
func (*Node) Boolean ¶
Returns [bool], true if the node is [bool].
If Node.ConvertSimilar was called then will call Node.String and then strconv.ParseBool, with failures returning false, false.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as false.
func (*Node) Bytes ¶
Returns []byte, true if the node is []byte.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as an empty []byte.
func (*Node) ConvertSimilar ¶
Returns a copy of this node for which similar values are allows and converted to the requested type. For example, Node.Float on an integer or unsigned integer would convert it to float.
func (*Node) Float ¶
Returns [float64], true if the node is [float64] or [float32].
If Node.ConvertSimilar was called then will convert [int64], [int32], [int16], [int8], [int], [uint64], [uint32], [uint16], [uint8], [uint] to a [float64] and return true (unless we are NoNode). Precision may be lost.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as 0.
func (*Node) Get ¶
Gets nested nodes from Map or StringMap by keys, recursively. Returns NoNode if a key is not found.
func (*Node) Integer ¶
Returns [int64], true if the node is [int64], [int32], [int16], [int8], or [int].
If Node.ConvertSimilar was called then will convert [uint64], [uint32], [uint16], [uint8], [uint], [float64], and [float32] to an [int64] and return true (unless we are NoNode). Precision may be lost.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as 0.
func (*Node) List ¶
Returns List, true if the node is List.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as an empty List.
func (*Node) Map ¶
Returns Map, true if the node is Map.
If Node.ConvertSimilar was called then will convert StringMap to a Map and return true.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as an empty Map.
func (*Node) NilMeansZero ¶
Returns a copy of this node for which nil values are allowed and interpreted as the zero value. For example, Node.String on nil would return an empty string.
func (*Node) Put ¶
Puts values in Map or StringMap by key. Returns false if failed (not a Map or StringMap).
func (*Node) String ¶
Returns [string], true if the node is [string].
If Node.ConvertSimilar was called then will convert any value to a string representation and return true (unless we are NoNode). Values are converted using MapKeyToString.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as an empty string.
func (*Node) StringList ¶
Returns []string, true if the node is List and all its elements are strings.
If Node.ConvertSimilar was called then will convert all elements to their string representations and return true. Values are converted using MapKeyToString.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as an empty List.
func (*Node) StringMap ¶
Returns StringMap, true if the node is StringMap.
If Node.ConvertSimilar was called then will convert Map to a StringMap and return true. Keys are converted using MapKeyToString.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as an empty StringMap.
func (*Node) UnsignedInteger ¶
Returns [uint64], true if the node is [uint64], [uint32], [uint16], [uint8], or [uint].
If Node.ConvertSimilar was called then will convert [int64], [int32], [int16], [int8], [int], [float64], and [float32] to an [uint64] and return true (unless we are NoNode). Precision may be lost.
By default will fail on nil values. Call Node.NilMeansZero to interpret nil as 0.
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 ¶
type ReflectField struct {
// contains filtered or unexported fields
}
type ReflectFields ¶
type ReflectFields map[string]ReflectField // ARD name
type Reflector ¶
type Reflector struct { IgnoreMissingStructFields bool NilMeansZero bool StructFieldTags []string // in order StructFieldNameMapper StructFieldNameMapperFunc // contains filtered or unexported fields }
func NewReflector ¶
func NewReflector() *Reflector
func (*Reflector) NewReflectFields ¶
func (self *Reflector) NewReflectFields(type_ reflect.Type) ReflectFields
func (*Reflector) PackReflect ¶
type StringMap ¶
An alias used to signify a map of ARD Value in which the key is always [string]. This alias is introduced for compability with certain parsers and encoders.
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
An alias used to signify that ARD values are expected, namely primitives, List, Map, and StringMap nested to any depth.
func ConvertMapsToStringMaps ¶ added in v0.2.0
Converts any Map to StringMap recursively, ensuring that no Map will be present. Conversion happens in place, unless the input is itself a Map, in which case a new StringMap will be returned.
Keys are converted using MapKeyToString.
Returns true if any conversion occurred.
func ConvertStringMapsToMaps ¶ added in v0.2.0
Converts any StringMap to Map recursively, ensuring that no StringMap will be present. Conversion happens in place, unless the input is itself a StringMap, in which case a new Map will be returned.
Returns true if any conversion occurred.
func Copy ¶ added in v0.2.0
Deep copy.
The input can be a mix of ARD and non-ARD values (e.g. Go structs). Non-ARD values will be left as is, thus the returned may not be valid ARD. To ensure a valid ARD result use ValidCopy.
Recurses into Map, StringMap, and List, creating new instances of each. Thus a Map is copied into a new Map and a StringMap is copied into a new StringMap. To convert them to a unified map type use CopyStringMapsToMaps or CopyMapsToStringMaps.
func CopyMapsToStringMaps ¶ added in v0.2.0
Like Copy but converts all Map to StringMap.
Keys are converted using MapKeyToString.
For in-place conversion use ConvertStringMapsToMaps.
func CopyStringMapsToMaps ¶ added in v0.2.0
Like Copy but converts all StringMap to Map.
For in-place conversion use ConvertStringMapsToMaps.
func DecodeMessagePack ¶
func DecodeTemplate ¶ added in v0.2.0
func Merge ¶ added in v0.2.2
Deep merge of source value into target value. Map and StringMap are merged key by key, recursively.
When appendList is true then target list elements are appended to the source list, otherwise the source list is overridden (copied over).
The source value remains safe, in that all merged data is copied (via Copy) into the target, thus any changes made to the target will not affect the source. On the other hand, the target value is changed in place. Note that for arguments that are not Map or StringMap you must use the return value from this function because it may return a new target value, e.g. a new List slice when appendList is true. Thus a safe way to use this function is like so:
target = Merge(target, source, true)
func ReadJSON ¶
Reads JSON from an io.Reader and decodes it into an ARD Value.
If useStringMaps is true returns maps as StringMap, otherwise they will be Map.
func ReadMessagePack ¶
Reads CBOR from an io.Reader and decodes it into an ARD Value.
If useStringMaps is true returns maps as StringMap, otherwise they will be Map.
func ReadXJSON ¶ added in v0.2.0
Reads JSON from an io.Reader and decodes it into an ARD Value while interpreting the xjson extensions.
If useStringMaps is true returns maps as StringMap, otherwise they will be Map.
func Roundtrip ¶
Encodes and then decodes the value via a supported format.
Supported formats are "yaml", "json", "xjson", "xml", "cbor", and "messagepack".
While this function can be used to "canonicalize" values to ARD, it is generally be more efficient to call ValidCopy instead.
func RoundtripCBOR ¶
func RoundtripJSON ¶
func RoundtripMessagePack ¶
func RoundtripXJSON ¶ added in v0.2.0
func RoundtripXML ¶ added in v0.2.0
func RoundtripYAML ¶
func ValidCopy ¶ added in v0.2.0
Deep copy and return a valid ARD value.
The input can be a mix of ARD and non-ARD values (e.g. Go structs). The returned value is guaranteed to be valid ARD. This works by reflecting any non-ARD via the provided *Reflector. The reflector argument can be nil, in which case a default reflector will be used. To leave non-ARD values as is use Copy.
This function can be used to "canonicalize" values to ARD, for which is should generally be more efficient than calling Roundtrip.
Recurses into Map, StringMap, and List, creating new instances of each. Thus a Map is copied into a new Map and a StringMap is copied into a new StringMap. To convert them to a unified map type use ValidCopyStringMapsToMaps or ValidCopyMapsToStringMaps.
func ValidCopyMapsToStringMaps ¶ added in v0.2.0
Like ValidCopy but converts all Map to StringMap.
Keys are converted using MapKeyToString.
For in-place conversion use ConvertMapsToStringMaps.
func ValidCopyStringMapsToMaps ¶ added in v0.2.0
Like ValidCopy but converts all StringMap to Map.
For in-place conversion use ConvertStringMapsToMaps.
type XJSONBytes ¶ added in v0.2.0
type XJSONBytes []byte
func (XJSONBytes) MarshalJSON ¶ added in v0.2.0
func (self XJSONBytes) MarshalJSON() ([]byte, error)
(json.Marshaler interface)
type XJSONInteger ¶ added in v0.2.0
type XJSONInteger int64
func (XJSONInteger) MarshalJSON ¶ added in v0.2.0
func (self XJSONInteger) MarshalJSON() ([]byte, error)
(json.Marshaler interface)
type XJSONMap ¶ added in v0.2.0
type XJSONMap Map
func (XJSONMap) MarshalJSON ¶ added in v0.2.0
(json.Marshaler interface)
type XJSONMapEntry ¶ added in v0.2.0
func UnpackXJSONMapEntry ¶ added in v0.2.0
func UnpackXJSONMapEntry(entry Value, useStringMaps bool) (*XJSONMapEntry, bool)
type XJSONUInteger ¶ added in v0.2.0
type XJSONUInteger uint64
func (XJSONUInteger) MarshalJSON ¶ added in v0.2.0
func (self XJSONUInteger) MarshalJSON() ([]byte, error)
(json.Marshaler interface)
type XMLBytes ¶ added in v0.2.0
type XMLBytes struct {
// contains filtered or unexported fields
}
func (XMLBytes) MarshalXML ¶ added in v0.2.0
(xml.Marshaler interface)
type XMLList ¶ added in v0.2.0
type XMLList struct {
Entries []any
}
func (XMLList) MarshalXML ¶ added in v0.2.0
(xml.Marshaler interface)
type XMLMap ¶ added in v0.2.0
type XMLMap struct {
// contains filtered or unexported fields
}
func (XMLMap) MarshalXML ¶ added in v0.2.0
(xml.Marshaler interface)
type XMLMapEntry ¶ added in v0.2.0
type XMLMapEntry struct {
// contains filtered or unexported fields
}
func NewXMLMapEntry ¶ added in v0.2.0
func NewXMLMapEntry(element *etree.Element) (XMLMapEntry, error)
func (XMLMapEntry) MarshalXML ¶ added in v0.2.0
func (self XMLMapEntry) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error
(xml.Marshaler interface)
type XMLNil ¶ added in v0.2.0
type XMLNil struct{}
func (XMLNil) MarshalXML ¶ added in v0.2.0
(xml.Marshaler interface)
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