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
Copy Markdown

@iamtakingiteasy iamtakingiteasy commented Feb 20, 2026

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.

Changes conflict with #183, a rebase of other will be necessary if either is merged.

@iamtakingiteasy
Copy link
Copy Markdown
Author

Removed unnecessary dispatches.

@iamtakingiteasy
Copy link
Copy Markdown
Author

Added handling of collections cases in nested struct fields.

…and arrays

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

Ensured that addressable values are always created.

@iamtakingiteasy
Copy link
Copy Markdown
Author

Restored changes after accidental push

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