Friday, January 8, 2021

How to fetch Session Id of JSONObject?

public static String extractSessionIDFromGetSessionId(String jsonObject) throws ParseException {

String methodName = "extractSessionIDFromGetSessionId";

LOGGER.debug(CLASS_NAME + "/" + methodName + "; jsonObject = " + jsonObject);

System.out.println(CLASS_NAME + "/" + methodName + "; jsonObject = " + jsonObject);


JSONParser parser = new JSONParser();

String sessionId = "";

System.out.println("JSON object is :" + jsonObject);

LOGGER.debug("JSON object is :" + jsonObject);


Object obj = parser.parse(jsonObject);

JSONObject jo = (JSONObject) obj;

sessionId = jo.get("sessionId").toString();

System.out.println("SessionId is : " + sessionId);


System.out.println("Exiting from the method : " + methodName);

LOGGER.debug("Exiting from the method : " + methodName);

return sessionId;

}

NOTE: JSON Jar is required


No comments:

Post a Comment

Content Assist set up in Eclipse

# Open the Eclipse application # Navigate to Windows > click on Preferences # Navigate to Java and expand it # Navigate to Editor a...