utils

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorPropertyMissingInJSON = errors.New("There is no such property in the JSON document")

ErrorPropertyMissingInJSON when there's no such property in the JSON document

Functions

func CalcExpression added in v1.2.0

func CalcExpression(expression string) (string, error)

func FormatJSON

func FormatJSON(input string) (result string, err error)

FormatJSON formats a JSON string

func GetJSONCompositePropertyValue added in v1.2.0

func GetJSONCompositePropertyValue(input string, property string) (string, error)

GetJSONCompositePropertyValue returns composite property value digging inside complex JSON documents

func GetJSONProperty added in v1.2.0

func GetJSONProperty(input string, property string) (string, error)

GetJSONProperty returns the string value of a given property inside a JSON document

func GetPropertyValue added in v1.2.0

func GetPropertyValue(input string, property string) (string, error)

GetPropertyValue returns the json property value if input is json, otherwise tries to parse the value as query string and get property value

func GetServerAddress

func GetServerAddress() string

GetServerAddress returns ServerAddress variable

func IsArray added in v1.2.0

func IsArray(data interface{}) bool

func IsJSON

func IsJSON(s string) bool

IsJSON checks if a string is valid JSON or not

func IsObject added in v1.2.0

func IsObject(data interface{}) bool

func JSONDeserialize added in v1.2.0

func JSONDeserialize(input string) (map[string]interface{}, error)

JSONDeserialize deserializes a JSON string to interface map

func JSONSStringsAreEqual

func JSONSStringsAreEqual(input1 string, input2 string) (result bool, err error)

JSONSStringsAreEqual checks whether two JSON strings are actually equal JSON objects

func JSONSerialize added in v1.2.0

func JSONSerialize(input interface{}) (string, error)

JSONSerialize serializes an inteface to JSON string

func JoinContent

func JoinContent(value1 string, value2 string) string

JoinContent returns two contents joined as JSON if both are JSONs otherwise concatenates them

func JoinJSON

func JoinJSON(inputs ...*gabs.Container) *gabs.Container

JoinJSON merges two JSON strings

func SetServerAddress

func SetServerAddress(address string)

SetServerAddress sets ServerAddress variable

func UnWrapNonJSONStringIfNeeded

func UnWrapNonJSONStringIfNeeded(input string) string

UnWrapNonJSONStringIfNeeded wrapps non JSON string in NonJSONItem object

func WrapNonJSONStringIfNeeded

func WrapNonJSONStringIfNeeded(input string) (result string, err error)

WrapNonJSONStringIfNeeded wrapps non JSON string in NonJSONItem object

Types

type Cartesian

type Cartesian struct {
}

Cartesian gets all combinations of values for keys

func (Cartesian) CartesianDistribute

func (c Cartesian) CartesianDistribute(input [][]string) [][]string

CartesianDistribute getting full combinations distribution using cartesian combination algorithm - http://stackoverflow.com/a/15310051/613113

func (Cartesian) GetCombinations

func (c Cartesian) GetCombinations(inputMap map[string][]string) []map[string]string

GetCombinations returns an array of maps with all combinations built by a map with values "key1": ["1", "2"], "key2":["3", "4"] -> [{"key1":"1", "key2":"3"}, {"key1":"1", "key2":"4"}, {"key1":"2", "key2":"3"}, {"key1":"2", "key2":"4"}]

type RegexHelper

type RegexHelper struct {
}

func (RegexHelper) GetCollectionItems

func (rh RegexHelper) GetCollectionItems(input string, getRegexParts func(string) (string, string, bool)) ([]string, bool)

func (RegexHelper) GetStringPart

func (rh RegexHelper) GetStringPart(input string, pattern string, groupName string) (string, bool)

GetStringPart gets the value of the group name matching the input using the pattern

type StaticVariables

type StaticVariables struct {
	ServerAddress string
}

Variables is used for storing static variables

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL