Skip to content

Comments

Type Agnostic Flattening#7

Open
citruspi wants to merge 1 commit intojeremywohl:masterfrom
citruspi:type-agnostic-flattening
Open

Type Agnostic Flattening#7
citruspi wants to merge 1 commit intojeremywohl:masterfrom
citruspi:type-agnostic-flattening

Conversation

@citruspi
Copy link

This isn't necessarily ready to be merged, but I wanted to open a discussion around the handling of explicitly typed maps and slices. At the present moment, flatten will only truly flatten a string (which would be unmarshalled to a map[string]interface{}) or a variable which has been declared as a map[string]interface{} or []interface{}, which means that users who pass in an explicitly typed variable (e.g. map[string]string or []string) won't receive a completely flattened object.

e.g. see #5

The changes in this PR at the moment fix the problem for slices of strings ([]string) however there's a number of other explicit types that should theoretically be supported - booleans, numbers of various types, etc.

We could either explicitly support each of these, or simply try to catch them and copy to a []interface{}.

@jeremywohl
Copy link
Owner

Will take a look this weekend. Thanks.

@jeremywohl
Copy link
Owner

Revisiting this (long weekend! :). Still relevant? Do you have failing test cases you can supply, just to make things concrete?

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.

2 participants