Documentation
¶
Overview ¶
Package maml implements encoding and decoding of MAML (Minimal Abstract Markup Language).
MAML is a minimal configuration format that is human-readable and machine-parsable. For the specification, see https://maml.dev/spec/v0.1
The package provides Marshal/Unmarshal functions similar to encoding/json, and an AST parser in the ast subpackage for tooling use cases.
Index ¶
- func IsIdentifierKey(key string) bool
- func Marshal(v any) ([]byte, error)
- func QuoteString(s string) string
- func Stringify(v Value) string
- func Unmarshal(data []byte, v any) error
- type Decoder
- type Encoder
- type KeyValue
- type MarshalError
- type Marshaler
- type OrderedMap
- type ParseError
- type UnmarshalError
- type Unmarshaler
- type Value
- func (v Value) AsArray() []Value
- func (v Value) AsBool() bool
- func (v Value) AsFloat() float64
- func (v Value) AsInt() int64
- func (v Value) AsObject() *OrderedMap
- func (v Value) AsString() string
- func (v Value) Get(key string) (Value, bool)
- func (v Value) IsArray() bool
- func (v Value) IsBool() bool
- func (v Value) IsFloat() bool
- func (v Value) IsInt() bool
- func (v Value) IsNull() bool
- func (v Value) IsObject() bool
- func (v Value) IsString() bool
- func (v Value) Raw() any
- func (v Value) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsIdentifierKey ¶
IsIdentifierKey returns true if the key can be written as a bare identifier.
func QuoteString ¶
QuoteString quotes a string value with proper MAML escape sequences.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads and decodes MAML values from an input stream.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes MAML values to an output stream.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
type MarshalError ¶
type MarshalError struct {
Message string
}
MarshalError represents an error encountered during marshaling.
func (*MarshalError) Error ¶
func (e *MarshalError) Error() string
type Marshaler ¶
Marshaler is the interface implemented by types that can marshal themselves into MAML.
type OrderedMap ¶
type OrderedMap struct {
// contains filtered or unexported fields
}
OrderedMap is an ordered map of string keys to Values, preserving insertion order.
func (*OrderedMap) Entries ¶
func (m *OrderedMap) Entries() []KeyValue
Entries returns key-value pairs in insertion order.
func (*OrderedMap) Get ¶
func (m *OrderedMap) Get(key string) (Value, bool)
Get retrieves a value by key.
func (*OrderedMap) Keys ¶
func (m *OrderedMap) Keys() []string
Keys returns the keys in insertion order.
func (*OrderedMap) Set ¶
func (m *OrderedMap) Set(key string, value Value)
Set adds or updates a key-value pair, preserving insertion order.
type ParseError ¶
ParseError represents an error encountered during parsing.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type UnmarshalError ¶
type UnmarshalError struct {
Message string
}
UnmarshalError represents an error encountered during unmarshaling.
func (*UnmarshalError) Error ¶
func (e *UnmarshalError) Error() string
type Unmarshaler ¶
Unmarshaler is the interface implemented by types that can unmarshal a MAML value.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value represents a MAML value.
func NewObject ¶
func NewObject(m *OrderedMap) Value
NewObject creates an object Value from an OrderedMap.
func (Value) AsObject ¶
func (v Value) AsObject() *OrderedMap
AsObject returns the OrderedMap value, or panics.