I have a convenience class wrapper for a Map, that looks something like this:
class MapWrapper {
private Map<String, Integer> wrapped = new HashMap<>();
public void add(String key, Integer count) {/*implementation*/}
// Other modifiers
}
The reason that I'm not using a Map directly but rather the wrapper is because I need to use the methods to access the Map indirectly.
When I de/serialize this object, I would like the JSON to serialize as if the wrapper class wasn't there. E.G. I want:
{
"key1":1,
"key2":2
}
for my JSON in/output and not (what is the default just passing to GSON):
{
wrapped: {
"key1":1,
"key2":2
}
}
If it matters, this object will be contained within another so GSON contextual deserialization will be able to say that the Object is a MapWrapper and not just a Map.