Download Gson library and put in your project build path.
Java Object will be a pojo ResponsePojo with fields status,code and message.
Code:
String jsonString = "{\"status\": 200,\ "code\": \"007\",\"message\": \"working fine \"}";
Gson gson = new Gson();
//JSON to java object
jsonResponse = gson.toJson(jsonString );
ResponsePojo rp = gson.fromJson(jsonResponse , ResponsePojo .class);
Output:
{
"status": 200,
"code": "007",
"message": "working fine"
}
No comments:
Post a Comment