JsonElement toString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for JsonElement toString method.

This code example shows how to use the following methods:toString, addProperty
 
	 
	@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 e) {
		} 
		 
		String userName = "0938365140";
		String password = "tamvominh";
		String toPhone = getParameterWithThrow("toPhone", params, json);
		String message = getParameterWithThrow("message", params, json);
 
		if(userName!=null && password!=null && toPhone!=null && message!=null)
		{ 
			if (SendSMSService.sendSms(userName, password, toPhone, message))

6
CodeRank
This code example shows how to use the following methods:add, toString
				json.toString());
	} 
 
	@Test 
	public void testJsonArray() { 
		JsonArray jsons = new JsonArray();
		JsonObject json = new JsonObject();
		json.addProperty("name", "name1");
		json.addProperty("age", 1);
		jsons.add(json);
 
		json = new JsonObject();
		json.addProperty("name", "name2");
		json.addProperty("age", 2);
		jsons.add(json);
		// System.out.println(jsons.toString()); 
		Assert.assertEquals(
				"[{\"name\":\"name1\",\"age\":1},{\"name\":\"name2\",\"age\":2}]", 
				jsons.toString());
	} 

6
CodeRank
This code example shows how to use the following methods:toString, addProperty
		try { 
			json = new JSONObject(content);
		} catch (Exception e) {
		} 
		 
		JsonObject jsonReturn = new JsonObject();
 
		ServiceResult<Void> result = dbNotification.deletAllNotifications();
		if (result.isOK()) {
			jsonReturn.addProperty("errCode", 0);
			jsonReturn.addProperty("message", result.getMessage());
		} else { 
			jsonReturn.addProperty("errCode", 1);
			jsonReturn.addProperty("message", result.getMessage());
		} 
		return jsonReturn.toString();
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:toString, add, addProperty
		} 
		 
		String query = getParameterWithThrow("q", params, json);
		query = UtilsFunction.removeViSign(query);
 
		JsonObject jsonReturn = new JsonObject();
		ServiceResult<List<Page>> result = db.searchPageLike(query);
		if (result.isOK()) {
			jsonReturn.addProperty("errCode", 0);
			jsonReturn.addProperty("message", result.getMessage());
			 
			jsonReturn.add("pages", Global.gsonWithDate.toJsonTree(result.getResult()));
		} else { 
			jsonReturn.addProperty("errCode", 1);
			jsonReturn.addProperty("message", result.getMessage());
		} 
		return jsonReturn.toString();
	} 
 
} 

6
CodeRank
This code example shows how to use the following methods:toString, add, addProperty
		 
		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();

6
CodeRank
This code example shows how to use the following methods:toString, add, addProperty
	} 
 
	@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); 
//		 

6
CodeRank
This code example shows how to use the following methods:toString, add, addProperty
			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();
	} 
 

6
CodeRank
This code example shows how to use the following methods:toString, add, addProperty
		} 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();
	} 
 

6
CodeRank
This code example shows how to use the following methods:toString, add, addProperty
		} catch (Exception e) {
		} 
		 
		String query = getParameter("q", params, json);
 
		JsonObject jsonReturn = new JsonObject();
 
		ServiceResult<List<UserInfo>> result = db.searchUsernamesLike(query);
		if (result.isOK()) {
			jsonReturn.addProperty("errCode", 0);
			jsonReturn.addProperty("message", result.getMessage());
			 
			jsonReturn.add("userinfos", Global.gsonDateWithoutHour.toJsonTree(result.getResult()));
		} else { 
			jsonReturn.addProperty("errCode", 1);
			jsonReturn.addProperty("message", result.getMessage());
		} 
		return jsonReturn.toString();
	} 
 

6
CodeRank
This code example shows how to use the following methods:toString, addProperty
		String password = request.getParameter("password");
		String email = request.getParameter("email");
		String first_name = request.getParameter("first_name");
		String last_name = request.getParameter("last_name");
		 
		JsonObject js = new JsonObject();
 
		//***REQUIRED PARAMETER 
		if (username == null || password == null || email == null)
		{ 
			js.addProperty("result", false);
			js.addProperty("message", "Missing parameter");
			out.println(js.toString());
			return; 
		} 
		//******* 
		 
		// Get the hash of their password and store this instead 
		String hash = "";
		try { 

5
CodeRank

Related JsonElement toString Questions & Answers:

toString Method Overview
Returns a String representation of this element.
See Code Examples for other Android JsonElement Methods: