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

Don't use toString when ser. complex keys of unknown type #63

Open
EugenCepoi opened this issue May 5, 2015 · 3 comments
Open

Don't use toString when ser. complex keys of unknown type #63

EugenCepoi opened this issue May 5, 2015 · 3 comments

Comments

@EugenCepoi
Copy link
Contributor

http://stackoverflow.com/questions/30057860/genson-serialization-for-maps-with-complex-keys

@EugenCepoi
Copy link
Contributor Author

This behaviour can not be changed by default as people expect to ser/de by default a erased Map as a Map<String, Object>.
What can be done is provide an option to ser/de untyped Maps as complex maps. This should also work when runtime type is being used.

@kerler
Copy link

kerler commented Jun 16, 2016

+1. Eagerly waiting for your fix.

@aseovic
Copy link
Contributor

aseovic commented May 10, 2018

JSON object is not a good way to represent Java Maps in general, as it only works in a special case when Map keys are strings. This is why I am amazed that pretty much every JSON serialization framework (including the "standard", JSON-B) tries to do the same, and was pleasantly surprised when I saw that Genson actually treats some maps the way all Java maps should be represented in JSON: as arrays of entries, with keys and values.

What I would really like to see is the ability to treat all the maps that way, with no special handling for string-, int-, long-keyed maps that is currently there.

I know this breaks many assumptions and makes it more difficult to deserialize untyped objects into Map<String, Object> when the serialization of such map would then result in something completely different, but I'd argue that Map<String, Object> is the wrong choice anyway and that untyped objects should be deserialized as javax.json.JsonObject instead.

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

3 participants