Documentation
¶
Index ¶
- 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 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 RemoveObjectFromArrayByFieldValue(inArr interface{}, fieldName string, fieldValue string, occurrences int) (interface{}, int, error)
- 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 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 ¶
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 ¶
func GetStringIndex ¶
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.
Types ¶
This section is empty.