Documentation
¶
Index ¶
- func ExtractTopLevelField(fieldPath string) string
- func GetAllReferencedFields(fieldPaths []string) []string
- func GetFieldPathDepth(fieldPath string) int
- func GetNestedField(data interface{}, fieldPath string) (interface{}, bool)
- func IsNestedField(fieldName string) bool
- func NormalizeFieldPath(fieldPath string) string
- func SetNestedField(data map[string]interface{}, fieldPath string, value interface{}) error
- func ValidateFieldPath(fieldPath string) error
- type FieldAccessError
- type FieldAccessor
- type FieldPart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTopLevelField ¶
ExtractTopLevelField extracts top-level field name from nested field path Examples: "device.info.name" returns "device"
"data[0].name" returns "data" "a.b[0].c['key']" returns "a"
func GetAllReferencedFields ¶
GetAllReferencedFields gets all top-level fields referenced in nested field paths Example: ["device.info.name", "sensor.temperature", "data[0].value"] returns ["device", "sensor", "data"]
func GetFieldPathDepth ¶
GetFieldPathDepth gets the depth of field path
func GetNestedField ¶
GetNestedField gets field value from nested map or struct Supports complex operations like dot-separated field paths, array indices, Map keys Supported formats: - "device.info.name" (nested fields) - "data[0]" (array index) - "users[0].name" (field of array element) - "config['key']" (string key) - "items[0][1]" (multi-dimensional array) - "nested.data[0].field['key']" (mixed access)
func IsNestedField ¶
IsNestedField checks if field name contains dots or array indices (nested field)
func NormalizeFieldPath ¶
NormalizeFieldPath normalizes field path format
func SetNestedField ¶
SetNestedField sets field value in nested map, supports complex paths Automatically creates missing levels in the path
func ValidateFieldPath ¶
ValidateFieldPath validates if field path format is correct
Types ¶
type FieldAccessError ¶
FieldAccessError field access error
func (*FieldAccessError) Error ¶
func (e *FieldAccessError) Error() string
type FieldAccessor ¶
type FieldAccessor struct {
Parts []FieldPart
}
FieldAccessor field accessor structure for parsing complex field paths
func ParseFieldPath ¶
func ParseFieldPath(fieldPath string) (*FieldAccessor, error)
ParseFieldPath parses field path, supports complex access like dot notation, array index, Map keys Supported formats: - a.b.c (nested fields) - a.b[0] (array index) - a.b[0].c (field of array element) - a.b["key"] (string key) - a.b['key'] (string key) - a.b[123] (number key or array index) - a[0].b[1].c["key"] (mixed access)
type FieldPart ¶
type FieldPart struct {
Type string // "field", "array_index", "map_key"
Name string // Field name or key name
Index int // Array index (when Type is "array_index")
Key string // Map key (when Type is "map_key")
KeyType string // Key type: "string", "number"
}
FieldPart represents a single part of field path