Code example for JsonObject

Methods: toStringaddaddProperty

0
	} 
 
	@Override 
	public String process(Map<String, String[]> params, String content)
			throws Exception, RestfulException { 
		JsonObject jsonReturn = new JsonObject();
		JSONObject json = null;
		try { 
			json = new JSONObject(content);
		} catch (Exception ex) {
		} 
		String username = getParameterWithThrow("username", params, json);
		int mode = 0;
		try { 
			mode = Integer.parseInt(getParameter("mode", params, json));
		} catch (Exception e) {
		} 
//		String fromDateStr = getParameter("fromDate", params, json); 
//		String toDateStr = getParameter("toDate", params, json); 
//		 
//		Date fromDate = null, toDate = null; 
//		if (fromDateStr != null) { 
//			fromDate = Global.df.parse(fromDateStr); 
//		} 
//		if (toDateStr != null) { 
//			toDate = Global.df.parse(toDateStr); 
//		} 
//		if (fromDate != null && toDate != null && fromDate.after(toDate)) { 
//			throw new Exception(Global.messages.getString("invalid_date_format")); 
//		} 
		Date lastUpdate = null;
		try { 
			lastUpdate = Global.dfFull.parse(getParameter("lastUpdate", params, json));
		} catch (Exception e) {
		} 
		 
		ServiceResult<List<UserSubcribeProduct>> result = dbSubcribe
				.getUserSubscribeProductByUsernameEnhanced(username, mode, lastUpdate);
		if (result.isOK()) {
			jsonReturn.addProperty("errCode", 0);
			jsonReturn.addProperty("message", result.getMessage());
			jsonReturn.add("usersubscribeproducts", Global.gsonWithDate
					.toJsonTree(result.getResult()));
		} else { 
			jsonReturn.addProperty("errCode", 1);
			jsonReturn.addProperty("message", result.getMessage());
		} 
		return jsonReturn.toString();
	} 
} 
Experience pair programming with AI  Get Codota for Java