mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
CamelConverter - more fixes picked up in testing (#30601)
This commit is contained in:
parent
92426840d6
commit
a940eb1e80
2 changed files with 27 additions and 17 deletions
|
@ -28,15 +28,15 @@ Function Convert-ListToSnakeCase($list) {
|
|||
foreach ($value in $list) {
|
||||
if ($value -is [Hashtable]) {
|
||||
$new_value = Convert-DictToSnakeCase -dict $value
|
||||
} elseif ($value -is [Array]) {
|
||||
} elseif ($value -is [Array] -or $value -is [System.Collections.ArrayList]) {
|
||||
$new_value = Convert-ListToSnakeCase -list $value
|
||||
} else {
|
||||
$new_value = $value
|
||||
}
|
||||
$snake_list.Add($new_value) | Out-Null
|
||||
[void]$snake_list.Add($new_value)
|
||||
}
|
||||
|
||||
return $snake_list
|
||||
return ,$snake_list
|
||||
}
|
||||
|
||||
# converts a dict/hashtable keys from camelCase to snake_case
|
||||
|
@ -51,14 +51,14 @@ Function Convert-DictToSnakeCase($dict) {
|
|||
$value = $dict_entry.Value
|
||||
if ($value -is [Hashtable]) {
|
||||
$snake_dict.$snake_key = Convert-DictToSnakeCase -dict $value
|
||||
} elseif ($value -is [Array]) {
|
||||
} elseif ($value -is [Array] -or $value -is [System.Collections.ArrayList]) {
|
||||
$snake_dict.$snake_key = Convert-ListToSnakeCase -list $value
|
||||
} else {
|
||||
$snake_dict.$snake_key = $value
|
||||
}
|
||||
}
|
||||
|
||||
return $snake_dict
|
||||
return ,$snake_dict
|
||||
}
|
||||
|
||||
# this line must stay at the bottom to ensure all defined module parts are exported
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue