Documentation
¶
Index ¶
- func FromJSON(jsonStr string, target interface{})
- func FromJSONE(jsonStr string, target interface{}) error
- func ToFloat64Map(value interface{}) map[string]float64
- func ToFloat64MapE(value interface{}) (map[string]float64, error)
- func ToFloat64Slice(value interface{}) []float64
- func ToFloat64SliceE(value interface{}) ([]float64, error)
- func ToIntMap(value interface{}) map[string]int
- func ToIntMapE(value interface{}) (map[string]int, error)
- func ToIntSlice(value interface{}) []int
- func ToIntSliceE(value interface{}) ([]int, error)
- func ToJSON(value interface{}) string
- func ToJSONE(value interface{}) (string, error)
- func ToMap(value interface{}) map[string]interface{}
- func ToMapE(value interface{}) (map[string]interface{}, error)
- func ToMapFromJSON(jsonStr string) map[string]interface{}
- func ToMapFromJSONE(jsonStr string) (map[string]interface{}, error)
- func ToMapT[K comparable, V any](value interface{}) map[K]V
- func ToMapTE[K comparable, V any](value interface{}) (map[K]V, error)
- func ToSlice(value interface{}) []interface{}
- func ToSliceE(value interface{}) ([]interface{}, error)
- func ToSliceFromJSON(jsonStr string) []interface{}
- func ToSliceFromJSONE(jsonStr string) ([]interface{}, error)
- func ToSliceT[T any](value interface{}) []T
- func ToSliceTE[T any](value interface{}) ([]T, error)
- func ToStringMap(value interface{}) map[string]string
- func ToStringMapE(value interface{}) (map[string]string, error)
- func ToStringSlice(value interface{}) []string
- func ToStringSliceE(value interface{}) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromJSON ¶
func FromJSON(jsonStr string, target interface{})
FromJSON converts JSON string to specified type.
func ToFloat64Map ¶
ToFloat64Map converts any type to map[string]float64.
func ToFloat64MapE ¶
ToFloat64MapE converts any type to map[string]float64 with error.
func ToFloat64Slice ¶
func ToFloat64Slice(value interface{}) []float64
ToFloat64Slice converts any type to []float64.
func ToFloat64SliceE ¶
ToFloat64SliceE converts any type to []float64 with error.
func ToIntSliceE ¶
ToIntSliceE converts any type to []int with error.
func ToMap ¶
func ToMap(value interface{}) map[string]interface{}
ToMap converts any type to map[string]interface{}.
func ToMapFromJSON ¶
ToMapFromJSON converts JSON string to map[string]interface{}.
func ToMapFromJSONE ¶
ToMapFromJSONE converts JSON string to map[string]interface{} with error.
func ToMapT ¶
func ToMapT[K comparable, V any](value interface{}) map[K]V
ToMapT converts any type to map[K]V. This is a generic version of ToMap that returns a map with key type K and value type V. It uses reflection caching to improve performance for repeated conversions.
Examples:
// Convert to map[string]string strMap := ToMapT[string, string](value) // Convert to map[string]int intMap := ToMapT[string, int](value) // Convert to map[int]float64 floatMap := ToMapT[int, float64](value)
func ToMapTE ¶
func ToMapTE[K comparable, V any](value interface{}) (map[K]V, error)
ToMapTE converts any type to map[K]V with error. This is a generic version of ToMapE that returns a map with key type K and value type V. It uses reflection caching to improve performance for repeated conversions.
Examples:
// Convert to map[string]string with error handling strMap, err := ToMapTE[string, string](value) // Convert to map[string]int with error handling intMap, err := ToMapTE[string, int](value) // Convert to map[int]float64 with error handling floatMap, err := ToMapTE[int, float64](value)
func ToSlice ¶
func ToSlice(value interface{}) []interface{}
ToSlice converts any type to []interface{}.
func ToSliceE ¶
func ToSliceE(value interface{}) ([]interface{}, error)
ToSliceE converts any type to []interface{} with error.
func ToSliceFromJSON ¶
func ToSliceFromJSON(jsonStr string) []interface{}
ToSliceFromJSON converts JSON string to []interface{}.
func ToSliceFromJSONE ¶
ToSliceFromJSONE converts JSON string to []interface{} with error.
func ToSliceT ¶
func ToSliceT[T any](value interface{}) []T
ToSliceT converts any type to []T. This is a generic version of ToSlice that returns a slice of type T. It uses reflection caching to improve performance for repeated conversions.
Examples:
// Convert to []string strSlice := ToSliceT[string](value) // Convert to []int intSlice := ToSliceT[int](value) // Convert to []float64 floatSlice := ToSliceT[float64](value)
func ToSliceTE ¶
ToSliceTE converts any type to []T with error. This is a generic version of ToSliceE that returns a slice of type T. It uses reflection caching to improve performance for repeated conversions.
Examples:
// Convert to []string with error handling strSlice, err := ToSliceTE[string](value) // Convert to []int with error handling intSlice, err := ToSliceTE[int](value) // Convert to []float64 with error handling floatSlice, err := ToSliceTE[float64](value)
func ToStringMap ¶
ToStringMap converts any type to map[string]string
func ToStringMapE ¶
ToStringMapE converts any type to map[string]string with error
func ToStringSlice ¶
func ToStringSlice(value interface{}) []string
ToStringSlice converts any type to []string
func ToStringSliceE ¶
ToStringSliceE converts any type to []string with error
Types ¶
This section is empty.