jdereg / json-io

Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer. Deep copy Java object graphs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serialize java Hashmap

thomasX opened this issue · comments

hello !
i use json-io for some years now and want to update from json.io 2.4 to json-io 4
but there are some problems with the new serialization format of maps:
the old forlmat was with @keys[,,,,],@Items[...]
this was the perfect format for serializing object to mongo.
in the mongo you can't query map keys containing '.' . But with the old format there was no problem.
it would be nice if we can switch between both formats

json-io does uses the @Keys/@Items format when a non-string key is used within a Map, otherwise it serializes to JSON in the format where the keys are String keys in json to the associated values.

If you want, you could add a flag that json-io would look at that would override this behavior. json-io has many existing options that can be turned on/off already. A pull request that adds support for this (and a test) would be welcomed.

Thank you for the PR on the @keys/@Items request. I plan to add a test and should get this rolled into a release this weekend.

Btw, what error are you getting when you pull this project down?

I am using Intellij, but this project should build just fine with: mvn clean install

I added the test case for the new flag and released the new version to Maven Central as 4.11.1. Normally, that may take a few hours before you will be able to reference it your pom.xml file.