Exclude map name when parsing GSon to JSON

1 week ago 10
ARTICLE AD BOX

I have something like this

String data = new Gson.toJson(myCoolObject)

myCoolObject has a HashMap. The resulting String ends up containing not just the keys/values of the map, but also the map's name. Like this..

{ "reallyUncoolMap": { "mapKey1": { "someValue1": "ABC", } "mapKey2": { "someValue2": "DEF", } } }

I would like it to be more like this, without the map's name:

{ "mapKey1": { "someValue1": "ABC", } "mapKey2": { "someValue2": "DEF", } }

but I have no idea how to do that...

Read Entire Article