Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow inline tag on custom map key types that implement encoding.Text*arshaler #50

Open
edkloczko opened this issue Aug 21, 2024 · 1 comment

Comments

@edkloczko
Copy link

In both the standard and experimental json libraries, I can use a custom type that implements the encoding.TextUnmarshaler and encoding.TextMarshaler interfaces as map keys. When using the inline flag, this is no longer allowed.

I think I understand why the original proposal stated:

The inlined field must be a Go struct that does not implement Marshaler or Unmarshaler

But I'm having a hard time understanding why the string-ish behavior for map keys couldn't be applied to inline tagged maps as well.

Thank you!

@edkloczko edkloczko changed the title Allow inlineing custom map key types that implement encoding.Text*arshaler Allow inline tag on custom map key types that implement encoding.Text*arshaler Aug 21, 2024
@dsnet
Copy link
Collaborator

dsnet commented Sep 25, 2024

I believe we could expand the restrictions, but permitting keys to support encoding.TextMarshaler complicates duplicate key detection. It's a solvable problem, but probably not something to solve for the first stable release of this module. The benefit of restricted features is that we can generally expand it in the future, but not the other way around.

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

No branches or pull requests

2 participants