• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JSONArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.appengine.labs.repackaged.org.json.JSONArray的典型用法代码示例。如果您正苦于以下问题:Java JSONArray类的具体用法?Java JSONArray怎么用?Java JSONArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSONArray类属于com.google.appengine.labs.repackaged.org.json包,在下文中一共展示了JSONArray类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parsePnoSettings

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
private static HashMap<String, String> parsePnoSettings(String settingsString) {
	if (!RiseUtils.strIsNullOrEmpty(settingsString)) {
		try {
			JSONArray settingsArray = new JSONArray(settingsString);

			HashMap<String, String> settings = new HashMap<String, String>();

			for (int i = 0; i < settingsArray.length(); i++) {
				JSONObject setting = settingsArray.getJSONObject(i);
				String name = setting.getString("name");
				String value = setting.optString("value", null);
				
				settings.put(name, value);
			}
			
			return settings;
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
	
	return null;
}
 
开发者ID:Rise-Vision,项目名称:rva,代码行数:24,代码来源:CompanyServiceImpl.java


示例2: serializeToJSON

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
@Override
public JSONObject serializeToJSON() throws JSONException {
	JSONObject root = new JSONObject();
	root.put("variable", this.variable);
	root.put("code", this.code.getId());
	root.put("datatype", this.type == null ? "" : this.type.toString()
			.toLowerCase());
	root.put("required", this.required);
	root.put("datatype_description", this.type_description);
	root.put("order", this.order);
	root.put("description", this.description);
	JSONArray values = new JSONArray();
	if (listValues != null) {
		for (Entry<String, String> e : listValues.entrySet()) {
			JSONObject j = new JSONObject();
			j.put("key", e.getKey());
			j.put("name", e.getValue());
			values.put(j);
		}
	}
	root.put("values", values);
	return root;
}
 
开发者ID:hasier,项目名称:voxpopuli,代码行数:24,代码来源:Attribute.java


示例3: fromJSON

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
/**
 * Creates a new instance of {@link SendRequest} based on the values derived from the specified {@code json}.
 * 
 * @param json
 *            the {@code JSONObject} from which the details are to be derived
 * @return The {@link SendRequest} derived from {@code json}.
 * @throws IllegalArgumentException
 *             If any of the required derived values are invalid.
 * @throws JSONException
 *             If {@code json} is malformed.
 * @throws NullPointerException
 *             If {@code json} is {@code null}.
 */
public static SendRequest fromJSON(JSONObject json) throws JSONException {
    SendRequest request = new SendRequest();
    request.setApiKey(json.getString("apiKey"));
    request.setHtml(json.optString("html", null));
    request.setSender(Contact.fromJSON(json.getJSONObject("sender")));
    request.setSubject(json.getString("subject"));
    request.setText(json.optString("text", null));

    JSONArray recipients = json.getJSONArray("recipients");
    for (int i = 0; i < recipients.length(); i++) {
        request.addRecipient(Contact.fromJSON(recipients.getJSONObject(i)));
    }

    return request;
}
 
开发者ID:neocotic,项目名称:mail-manager,代码行数:29,代码来源:SendRequest.java


示例4: toJSON

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
/**
 * Creates a {@code JSONObject} based on this {@link SendRequest}.
 * 
 * @return The derived {@code JSONObject}.
 * @throws JSONException
 *             If this {@link SendRequest} is malformed.
 */
public JSONObject toJSON() throws JSONException {
    JSONObject json = new JSONObject();
    json.put("apiKey", apiKey);
    json.putOpt("html", html);
    json.put("sender", sender.toJSON());
    json.put("subject", subject);
    json.putOpt("text", text);

    JSONArray array = new JSONArray();
    for (Contact recipient : recipients) {
        array.put(recipient.toJSON());
    }
    json.put("recipients", array);

    return json;
}
 
开发者ID:neocotic,项目名称:mail-manager,代码行数:24,代码来源:SendRequest.java


示例5: updateContestInfo

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
private static void updateContestInfo(Map<Test, Pair<Integer, Integer>> testsGraded, List<Test> tiesBroken, Entity contestInfo, StringBuilder errorLog) throws JSONException {
	SimpleDateFormat isoFormat = new SimpleDateFormat("hh:mm:ss a EEEE MMMM d, yyyy zzzz");
	isoFormat.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
	contestInfo.setProperty("updated", isoFormat.format(new Date()).toString());

	List<String> testsGradedList = new ArrayList<String>();
	for (Test test : testsGraded.keySet()) {
		if (testsGraded.get(test).x > 0 && tiesBroken.contains(test)) {
			testsGradedList.add(test.toString());
		}
	}
	contestInfo.setProperty("testsGraded", testsGradedList);

	JSONObject testsGradedJSON = new JSONObject();
	for (Entry<Test, Pair<Integer, Integer>> entry : testsGraded.entrySet()) {
		JSONArray numTests = new JSONArray().put(entry.getValue().x).put(entry.getValue().y);
		testsGradedJSON.put(entry.getKey().toString(), numTests);
	}

	contestInfo.setProperty("testsGradedNums", new Text(testsGradedJSON.toString()));

	contestInfo.setProperty("errorLog", new Text(errorLog.toString()));

	datastore.put(contestInfo);
}
 
开发者ID:sushain97,项目名称:contestManagement,代码行数:26,代码来源:Main.java


示例6: savePnoSettings

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
public void savePnoSettings(CompanyInfo company) throws ServiceFailedException {
	String url = createCompanyResource(company.getId());
	String settingsString = "";

	try {
		JSONArray settingsArray = new JSONArray();
		// iterate through list to add elements.
		for (String key : company.getSettings().keySet()){
			JSONObject setting = new JSONObject();
			setting.put("name", key);
			setting.put("value", company.getSettings().get(key));
			settingsArray.put(setting);
		}
		
		settingsString = settingsArray.toString();
		
	} catch (JSONException e) {
		e.printStackTrace();
		
		throw new ServiceFailedException();
	}
	
	Form form = new Form();
	
	form.add(CompanyAttribute.SETTINGS, settingsString);
	
	put(url, form);
}
 
开发者ID:Rise-Vision,项目名称:rva,代码行数:29,代码来源:CompanyServiceImpl.java


示例7: sendJSONError

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
private static void sendJSONError(HttpServletRequest req,
		HttpServletResponse resp, String path, int error, String errorStr)
		throws IOException {
	try {
		JSONArray json = new JSONArray();
		json.put(JSONUtils.getJSONError(error, errorStr));
		JSONUtils.sendJSON(json.toString(), resp);
	} catch (JSONException e) {
		// TODO Error ??
		e.printStackTrace();
	}
}
 
开发者ID:hasier,项目名称:voxpopuli,代码行数:13,代码来源:Utils.java


示例8: serializeToJSON

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
@Override
public JSONObject serializeToJSON() throws JSONException {
	JSONObject root = new JSONObject();
	root.put("service_code", this.serviceCode.getId());

	JSONArray attrs = new JSONArray();
	for (Attribute a : attributes) {
		attrs.put(a.serializeToJSON());
	}
	root.put("attributes", attrs);
	return root;
}
 
开发者ID:hasier,项目名称:voxpopuli,代码行数:13,代码来源:ServiceDefinition.java


示例9: doGet

import com.google.appengine.labs.repackaged.org.json.JSONArray; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// get Access to Mirror Api
	Mirror mirror = getMirror(req);
	
	// get TimeLine
	Timeline timeline = mirror.timeline();
		
	try {
	    JSONObject json = new JSONObject(retrieveIPool());
	    JSONArray arr = json.getJSONArray("documents");
	    JSONArray media = new JSONArray();
	    
	    String title = null;
	    String content = null;
	    String URL = null;
	    
	    for (int i = 0; i < arr.length(); i++) {
	        title = arr.getJSONObject(i).getString("title");
	        // maybe for future use but for tts needs to be stripped from html tags
	        //content = arr.getJSONObject(i).getString("content");
	        media = arr.getJSONObject(i).getJSONArray("contentReferences");   
	    }
	    		    
	    if (media.length()!=0){
		    for (int i = 0; i < media.length(); i++) {
		    	URL = media.getJSONObject(i).getString("externalUrl");   
		    }
	    }
    
	    String html = "<article class=\"photo\">\n  <img src=\""+URL+"\" width=\"100%\" height=\"100%\">\n  <div class=\"overlay-gradient-tall-dark\"/>\n  <section>\n    <p class=\"text-auto-size\">"+title+"</p>\n  </section>\n</article>";
	    
	 // create a timeline item
		TimelineItem timelineItem = new TimelineItem()
			//.setSpeakableText(content)
			.setSpeakableText(title)
			.setHtml(html)
			.setDisplayTime(new DateTime(new Date()))
			.setNotification(new NotificationConfig().setLevel("Default"));
		
		// add menu items with built-in actions
		List<MenuItem> menuItemList = new ArrayList<MenuItem>();
		menuItemList.add(new MenuItem().setAction("DELETE"));
		menuItemList.add(new MenuItem().setAction("READ_ALOUD"));
		menuItemList.add(new MenuItem().setAction("TOGGLE_PINNED"));
		timelineItem.setMenuItems(menuItemList);
		
		// insert the crad into the timeline
		timeline.insert(timelineItem).execute();
		
		//print out results on the web browser
		resp.setContentType("text/html; charset=utf-8");
		//resp.setCharacterEncoding("UTF-8");
		resp.getWriter().println(
				"<html><head><meta http-equiv=\"refresh\" content=\"3;url=/index.html\"></head> "
						+ "<body>"+html+"</body></html>");
	} catch (JSONException e) {
	    
	    StringWriter errors = new StringWriter();
	    e.printStackTrace(new PrintWriter(errors));
	    String error =  errors.toString();
	    
	    //resp.setContentType("text/html; charset=utf-8");
	    resp.setCharacterEncoding("UTF-8");
		resp.getWriter().println(
				"<html><head><meta http-equiv=\"refresh\" content=\"3;url=/index.html\"></head> "
						+ "<body>JSON Exception " +error+" </body></html>");
	}
}
 
开发者ID:ipool,项目名称:GlassPool,代码行数:70,代码来源:IpoolAPIClient.java



注:本文中的com.google.appengine.labs.repackaged.org.json.JSONArray类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CacheableDeserializerIdManager类代码示例发布时间:2022-05-23
下一篇:
Java EnvironmentOutcome类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap