private static class MapDecoder implements JsonDeserializer<Map<String, String>> {
@Override
public Map<String, String> deserialize(JsonElement arg0, Type arg1,
JsonDeserializationContext arg2) throws JsonParseException {
if (!arg0.isJsonObject()) {
throw new JsonParseException(arg0.toString() + " is not Json Object, cannot convert to map");
}
JsonObject objs = arg0.getAsJsonObject();
Map<String, String> map = new HashMap<String ,String>();
for (Entry<String, JsonElement> e : objs.entrySet()) {
if (!e.getValue().isJsonPrimitive()) {
throw new JsonParseException(e.getValue().toString() + " is not a Json primitive," + arg0 + " can not convert to map");
}
map.put(e.getKey(), e.getValue().getAsString());
}
return map;
}