gson object to json code example
Example 1: object to json string android
Gson gson = new Gson();
String json = gson.toJson(myObj);
Example 2: json to object gson
User user= gson.fromJson(jsonInString, User.class);
// where jsonInString is your json {"userId":"1","userName":"Yasir"}