Documentation
¶
Index ¶
- func ConvertToJSONInterface(data *yaml.Node) *interface{}
- func ConvertToJSONobject(data *yaml.Node) map[string]interface{}
- func ConvertToYamlNode(data interface{}) *yaml.Node
- func DeepCopyArray(data []interface{}) []interface{}
- func DeepCopyObject(data map[string]interface{}) map[string]interface{}
- func GetBoolField(object map[string]interface{}, fieldName string) (bool, error)
- func GetBoolIndex(arr []interface{}, index int) (bool, error)
- func GetFloat64Field(object map[string]interface{}, fieldName string) (float64, error)
- func GetFloat64Index(arr []interface{}, index int) (float64, error)
- func GetInt64Field(object map[string]interface{}, fieldName string) (int64, error)
- func GetInt64Index(arr []interface{}, index int) (int64, error)
- func GetObjectArrayField(object map[string]interface{}, fieldName string) ([]map[string]interface{}, error)
- func GetStringArrayField(object map[string]interface{}, fieldName string) ([]string, error)
- func GetStringField(object map[string]interface{}, fieldName string) (string, error)
- func GetStringIndex(arr []interface{}, index int) (string, error)
- func GetUInt64Field(object map[string]interface{}, fieldName string) (uint64, error)
- func GetUInt64Index(arr []interface{}, index int) (uint64, error)
- func RemoveObjectFromArrayByFieldValue(inArr interface{}, fieldName string, fieldValue string, occurrences int) (interface{}, int, error)
- func SetObjectArrayField(object map[string]interface{}, fieldName string, ...)
- func ToArray(arr interface{}) ([]interface{}, error)
- func ToObject(obj interface{}) (map[string]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToJSONInterface ¶ added in v0.1.12
func ConvertToJSONInterface(data *yaml.Node) *interface{}
func ConvertToJSONobject ¶ added in v0.1.12
func ConvertToJSONobject(data *yaml.Node) map[string]interface{}
func ConvertToYamlNode ¶ added in v0.1.12
func ConvertToYamlNode(data interface{}) *yaml.Node
func DeepCopyArray ¶ added in v0.1.10
func DeepCopyArray(data []interface{}) []interface{}
DeepCopyArray implements a poor man's deepcopy by jsonify/de-jsonify
func DeepCopyObject ¶ added in v0.1.10
DeepCopyObject implements a poor man's deepcopy by jsonify/de-jsonify
func GetBoolField ¶
GetBoolField returns a boolean from an object field. Returns an error if the field is not a boolean, or is not found.
func GetBoolIndex ¶
GetBoolIndex returns a boolean-value from an array index. Returns an error if the entry is not a boolean.
func GetFloat64Field ¶ added in v0.1.28
GetFloat64Field returns a float64 from an object field. Returns an error if the field is not a float, or is not found.
func GetFloat64Index ¶ added in v0.1.28
GetFloat64Index returns a float64-value from an array index. Returns an error if the entry is not a float.
func GetInt64Field ¶ added in v0.1.32
GetInt64Field returns an int64 from an object field. Returns an error if the field is not an integer, or is not found.
func GetInt64Index ¶ added in v0.1.32
GetInt64Index returns an int64-value from an array index. Returns an error if the entry is not an integer.
func GetObjectArrayField ¶
func GetObjectArrayField(object map[string]interface{}, fieldName string) ([]map[string]interface{}, error)
GetObjectArrayField returns a new slice containing all objects from the array referenced by fieldName. If the field is not an array, it returns an error. If the field doesn't exist it returns an empty array. Any entry in the array that is not an object will be omitted from the returned slice.
func GetStringArrayField ¶ added in v0.1.10
GetStringArrayField returns a new slice containing all strings from the array referenced by fieldName. If the field is not an array, it returns an error. If the field doesn't exist it returns an empty array. Any entry in the array that is not a string will be omitted from the returned slice.
func GetStringField ¶
GetStringField returns a string-value from an object field. Returns an error if the field is not a string, or is not found.
func GetStringIndex ¶
GetStringIndex returns a string-value from an array index. Returns an error if the entry is not a string.
func GetUInt64Field ¶ added in v0.1.28
GetUInt64Field returns a uint64 from an object field. Returns an error if the field is not a unsigned integer, or is not found.
func GetUInt64Index ¶ added in v0.1.28
GetUInt64Index returns a uint64-value from an array index. Returns an error if the entry is not an unsigned integer.
func RemoveObjectFromArrayByFieldValue ¶
func RemoveObjectFromArrayByFieldValue(inArr interface{}, fieldName string, fieldValue string, occurrences int, ) (interface{}, int, error)
RemoveObjectFromArrayByFieldValue returns a slice in which objects that match the field value are removed. Returns; new slice, # of removals, err. occurrences determines the maximum number of items to remove, use -1 for unlimited. Only returns an error if inArr is given (non-nil), and it is not an array/slice. But even then it still returns the input value, so it is transparent.
func SetObjectArrayField ¶ added in v0.1.14
func SetObjectArrayField(object map[string]interface{}, fieldName string, objectArray []map[string]interface{})
SetObjectArrayField sets an array in a parsed json object. This ensure it is of type []interface{}, such that a next call to GetObjectArrayField will work. If 'objectArray' is nil, then the field is deleted from the object.
Types ¶
This section is empty.