Is there a way to convert a String containing json to a HashMap, where every key is a json-key and the value is the value of the json-key? The json has no nested values. I a
Use TypeToken, as per the GSON FAQ:
Gson gson = new Gson(); Type stringStringMap = new TypeToken>(){}.getType(); Map map = gson.fromJson(json, stringStringMap);
No casting. No unnecessary object creation.