Documentation ¶
Overview ¶
Package dynamicobject provides a dynamic object.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamicObject ¶
type DynamicObject map[string]interface{}
DynamicObject defines a dynamic object which is a map of string to interface{}. The value of this map could also be a dynamic object, but in this case, its type must be `map[string]interface{}`, and should not be `map[interface{}]interface{}`.
func (DynamicObject) Get ¶
func (do DynamicObject) Get(field string) interface{}
Get gets the value of field 'field'
func (DynamicObject) GetString ¶
func (do DynamicObject) GetString(field string) string
GetString gets the value of field 'field' as string
func (*DynamicObject) Set ¶
func (do *DynamicObject) Set(field string, value interface{})
Set set the value of field 'field' to 'value'
func (*DynamicObject) UnmarshalYAML ¶
func (do *DynamicObject) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements yaml.Unmarshaler
the type of a DynamicObject field could be `map[interface{}]interface{}` if it is unmarshaled from yaml, but some packages, like the standard json package could not handle this type, so it must be converted to `map[string]interface{}`.
Note there's a bug with this function:
do := DynamicObject{} yaml.Unmarshal([]byte(`{"a": 1}`), &do) yaml.Unmarshal([]byte(`{"b": 2}`), &do)
the result of above code should be `{"a": 1, "b": 2}`, but it is `{"b": 2}`.