Try this:
Gson gson = new Gson();
String jsonInString = "{\"userId\":\"1\",\"userName\":\"Yasir\"}";
User user= gson.fromJson(jsonInString, User.class);
More Related Contents:
- Deserialize a List object with Gson?
- JAVA – Best approach to parse huge (extra large) JSON file
- gson throws MalformedJsonException
- How to parse JSON Array (Not Json Object) in Android
- Gson – convert from Json to a typed ArrayList
- Parse JSON file using GSON
- gson.toJson() throws StackOverflowError
- Query a JSONObject in java
- How to deserialize a list using GSON or another JSON library in Java?
- Trouble with Gson serializing an ArrayList of POJO’s
- Deserializing Generic Types with GSON
- How to prevent Gson from converting a long number (a json string ) to scientific notation format?
- How to convert a String to JsonObject using gson library
- Remove empty collections from a JSON with Gson
- How do I implement TypeAdapterFactory in Gson?
- Parsing nested JSON data using GSON
- Gson: Is there an easier way to serialize a map
- Jsonpath with Jackson or Gson
- com.google.gson.internal.LinkedTreeMap cannot be cast to my class [duplicate]
- How to keep fields sequence in Gson serialization
- Java – Gson parsing nested within nested
- GSON: How to get a case insensitive element from Json?
- Gson turn an array of data objects into json – Android
- Using a generic type with Gson
- Using Gson with Interface Types
- How can I prevent gson from converting integers to doubles
- Parsing a complex Json Object using GSON in Java
- GSON does not deserialize reference to outer class
- How to serialize a class with an interface?
- How to handle a NumberFormatException with Gson in deserialization a JSON response