Code example for JsonObject

Methods: toStringaddaddProperty

0
			q = getParameter("q", params, json);
			q = UtilsFunction.removeViSign(q);
		} catch (Exception e) {
		} 
 
		JsonObject jsonReturn = new JsonObject();
 
		ServiceResult<List<Product>> result = db.getListProductFromUsername(username, q, limit);
		if (result.isOK()) {
			jsonReturn.addProperty("errCode", 0);
			jsonReturn.addProperty("message", result.getMessage());
			 
			jsonReturn.add("products", Global.gsonWithDate.toJsonTree(result.getResult()));
		} else { 
			jsonReturn.addProperty("errCode", 1);
			jsonReturn.addProperty("message", result.getMessage());
		} 
		return jsonReturn.toString();
	} 
 
}