user6160039 :
Suppose I have json string
{"userId":"1","userName":"Yasir"}
now I have a class User
class User{
int userId;
String userName;
//setters and getters
}
Now How can I convert above json string to user class object
Sándor Juhos :
Try this:
Gson gson = new Gson();
String jsonInString = "{\"userId\":\"1\",\"userName\":\"Yasir\"}";
User user= gson.fromJson(jsonInString, User.class);
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=447121&siteId=1