Code example for JsonObject

Methods: toStringaddaddProperty

0
		 
		String username = getParameter("username", params, json);
		String password = getParameter("password", params, json);
		String userkey = getParameter("userkey", params, json);
 
		JsonObject jsonReturn = new JsonObject();
		 
		UtilsFunction.clearExpiredSession(); 
		 
		ServiceResult<UserInfo> result = db.login(username, password, userkey);
		if (result.isOK()) {
			jsonReturn.addProperty("errCode", 0);
			jsonReturn.addProperty("message", result.getMessage());
			 
			jsonReturn.add("userinfo", Global.gsonDateWithoutHour.toJsonTree(result.getResult()));
		} else { 
			jsonReturn.addProperty("errCode", 1);
			jsonReturn.addProperty("message", result.getMessage());
		} 
		return jsonReturn.toString();
	} 
 
} 
Connect your IDE to all the code out there  Get Codota for Java