How to convert Json to Java object using Gson -
this question has answer here:
- parse json file using gson 3 answers
suppose have json string
{"userid":"1","username":"yasir"}
now have class user
class user{ int userid; string username; //setters , getters }
now how can convert above json string user class object
try this:
gson gson = new gson(); string jsoninstring = "{\"userid\":\"1\",\"username\":\"yasir\"}"; user user= gson.fromjson(jsoninstring, user.class);
Comments
Post a Comment