Documentation ¶
Index ¶
- Variables
- func FilterJSONString(data string, keys []string, include bool) (map[string]any, string, error)
- func GetEnvOrDefault(k, defaultvalue string) string
- func GetKeys(hash map[string]any) []string
- func GetObjectAtKey(data map[string]any, path string) (any, error)
- func GetRequestData(data, overwrite map[string]any) (string, error)
- func GetStringAtKey(data map[string]any, path string) (string, error)
- func IntersectMaps(map1, map2 map[string]any) map[string]any
- func ParseImportPath(id string) (string, string, error)
- func SanitizePath(path string) string
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FilterJSONString ¶
FilterJSONString filters keys from a JSON string. It takes a JSON string, a list of keys to filter, and a boolean indicating whether to include or exclude those keys. It returns the filtered JSON object, the filtered JSON string, and any error.
func GetEnvOrDefault ¶
GetEnvOrDefault returns the value of the environment variable k if set, or defaultvalue if not set.
func GetObjectAtKey ¶
GetObjectAtKey recursively traverses a map[string]any to find the value at the given slash-delimited path. It can handle maps and slices in the path.
Example inputs:
data = { "foo": { "bar": [1, 2, 3] } }
path = "foo/bar/0"
Returns 1.
func GetRequestData ¶
GetRequestData marshals the provided data map into a JSON string. If overwrite is provided, it will override data. Returns the JSON string and any error from json.Marshal.
func GetStringAtKey ¶
GetStringAtKey returns the string value at the given slash-delimited path in the provided map[string]any data. It will attempt to convert values of other types like numbers to strings. Returns error if path not found or value is not a string or convertible type.
func IntersectMaps ¶
IntersectMaps takes two maps and returns a new map containing only the keys and values that exist in both input maps. For keys that exist in both maps but have different value types, the value from map2 is used. Nested maps are intersected recursively.
func ParseImportPath ¶
ParseImportPath parses a Restobject import path string into its object ID and path components.
func SanitizePath ¶
SanitizePath removes duplicate slashes and trailing slash from the provided path.
Types ¶
This section is empty.