Here you go:
import java.lang.reflect.Type;
import com.google.gson.reflect.TypeToken;
Type type = new TypeToken<Map<String, String>>(){}.getType();
Map<String, String> myMap = gson.fromJson("{'k1':'apple','k2':'orange'}", type);
More Related Contents:
- Why does Gson fromJson throw a JsonSyntaxException: Expected BEGIN_OBJECT but was BEGIN_ARRAY?
- “Expected BEGIN_OBJECT but was STRING at line 1 column 1”
- JSON parsing using Gson for Java
- How to sort Map values by key in Java?
- How do I write a custom JSON deserializer for Gson?
- Get nested JSON object with GSON using retrofit
- Polymorphism with gson
- Is default no-args constructor mandatory for Gson?
- Parsing JSON array into java.util.List with Gson
- Retrofit Expected BEGIN_OBJECT but was BEGIN_ARRAY
- What is the basic purpose of @SerializedName annotation in Android using Gson
- Using GSON to parse a JSON array
- creating Hashmap from a JSON String
- Java 8 LocalDateTime deserialized using Gson
- JSON GSON.fromJson Java Objects
- how to parse JSON file with GSON
- class A declares multiple JSON fields
- Dealing with randomly generated and inconsistent JSON field/key names using GSON
- Skip root element while deserializing json
- How to convert Json to Java object using Gson [duplicate]
- Setting Default value to a variable when deserializing using gson
- Java GSON: Getting the list of all keys under a JSONObject
- Gson – deserialization to specific object type based on field value
- Convert JSONObject to Map
- How to convert a string to a HashMap? [duplicate]
- Using gson to deserialize specific JSON field of an object
- Gson custom deseralizer for one variable in an object
- How to serialize Optional classes with Gson?
- Retrofit GSON serialize Date from json string into java.util.date
- How to handle a NumberFormatException with Gson in deserialization a JSON response