Download Gson library and put in your project build path.
Java Object will be a pojo javaObject with fields status,code and message.
Code:
Gson gson = new Gson();
jsonResponse = gson.toJson(javaObject);
log.info(" json string : " + jsonResponse);
Output:
{
"status": 200,
"code": "007",
"message": "working fine"
}
No comments:
Post a Comment