Skip to content

feature: extend deep mapping support to nested types, pointers, maps and arrays#176

Open
iamtakingiteasy wants to merge 1 commit intogo-viper:mainfrom
iamtakingiteasy:main
Open

feature: extend deep mapping support to nested types, pointers, maps and arrays#176
iamtakingiteasy wants to merge 1 commit intogo-viper:mainfrom
iamtakingiteasy:main

Conversation

@iamtakingiteasy
Copy link

Currently deep mapping is limited only to non-pointer slice elements.

This MR extends deep mapping, allowing to perform deep conversion on pointer types, including nested pointer types, arrays and maps.

To facilitate this, all container type mapping functions are extended with state to carry global default configuration / field overrides down the type hierarchy for recursive deep conversion.

Additionally, a new configuration option Indirect (and field-level tag option indirect) is added to allow conversion of nested maps/slices/arrays to their indirect/interface representations, e.g. having map[string]any in output instead of map[string]map[string]any and []any instead of [][]any and [123]any on the top level.

Explicitly supported cases are covered by tests in all permutations.

…and arrays

Signed-off-by: Alexander Tumin <iamtakingiteasy@eientei.org>
@iamtakingiteasy
Copy link
Author

Removed unnecessary dispatches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant