Code example for JsonObject

Methods: toStringaddaddProperty

0
		} catch (Exception e) {
		} 
		 
		String username = getParameter("username", params, json);
 
		JsonObject jsonReturn = new JsonObject();
 
		ServiceResult<List<Comment>> result = db.getListPageFromUsername(username);
		if (result.isOK()) {
			jsonReturn.addProperty("errCode", 0);
			jsonReturn.addProperty("message", result.getMessage());
			 
			jsonReturn.add("comments", Global.gsonWithDate.toJsonTree(result.getResult()));
		} else { 
			jsonReturn.addProperty("errCode", 1);
			jsonReturn.addProperty("message", result.getMessage());
		} 
		return jsonReturn.toString();
	} 
 
}