package main

// getString extracts a string value from content map.
func getString(content map[string]any, key string) string {
	if v, ok := content[key].(string); ok {
		return v
	}
	return ""
}

// getInt extracts an int value from content map (handles float64 from JSON).
func getInt(content map[string]any, key string, defaultVal int) int {
	if v, ok := content[key].(float64); ok {
		return int(v)
	}
	if v, ok := content[key].(int); ok {
		return v
	}
	return defaultVal
}

// getSlice extracts a slice of maps from content.
func getSlice(content map[string]any, key string) []map[string]any {
	if v, ok := content[key].([]any); ok {
		result := make([]map[string]any, 0, len(v))
		for _, item := range v {
			if m, ok := item.(map[string]any); ok {
				result = append(result, m)
			}
		}
		return result
	}
	return nil
}
