當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.get方法代碼示例

本文整理匯總了Java中net.sf.json.JSONObject.get方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.get方法的具體用法?Java JSONObject.get怎麽用?Java JSONObject.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.get方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleJson

import net.sf.json.JSONObject; //導入方法依賴的package包/類
public void handleJson(String jsonContent) throws Exception {
	JSONArray array = JSONArray.fromObject(jsonContent);
	JSONObject object = null;
	int l = array.size();
	for (int i = 0; i < l; i++) {
		object = array.getJSONObject(i);
		JSONObject obj1 = (JSONObject) object.get("data");
		JSONObject obj2 = (JSONObject) obj1.get("archives");
		for (int j = 0; j < 20; j++) {
			JSONObject obj3 = (JSONObject) obj2.get(String.valueOf(j));
			Bilibili video = new Bilibili();
			video.setAid(Integer.parseInt(obj3.get("aid").toString()));
			video.setTid(Integer.parseInt(obj3.get("tid").toString()));
			video.setTname((obj3.get("tname")).toString());
			video.setTitle((obj3.get("title")).toString());
			video.setAuthor((obj3.get("author")).toString());
			JSONObject obj4 = (JSONObject) obj3.get("stat");
			video.setCoin(Integer.parseInt(obj4.get("coin").toString()));
			video.setFavorite(Integer.parseInt(obj4.get("favorite").toString()));
			JDBC.insertBilibiliData(conn, video);
		}
	}
}
 
開發者ID:bighuang624,項目名稱:BiliInfoCrawler,代碼行數:24,代碼來源:Test.java

示例2: getVideoNumber

import net.sf.json.JSONObject; //導入方法依賴的package包/類
public int getVideoNumber(String jsonContent) throws Exception {
	JSONArray array = JSONArray.fromObject(jsonContent);
	JSONObject object = null;
	int l = array.size();
	int videoNumber = 0;
	for (int i = 0; i < l; i++) {
		object = array.getJSONObject(i);
		JSONObject obj1 = (JSONObject) object.get("data");
		JSONObject obj2 = (JSONObject) obj1.get("page");
		videoNumber = Integer.parseInt(obj2.get("count").toString());
	}
	return videoNumber;
}
 
開發者ID:bighuang624,項目名稱:BiliInfoCrawler,代碼行數:14,代碼來源:Test.java

示例3: service

import net.sf.json.JSONObject; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
	String spellRequestJSON = req.getReader().readLine();

	JSONObject jsonReqObject = JSONObject.fromObject(spellRequestJSON);

	jsonReqObject.get("params");

	SpellcheckRequest spellRequest = new SpellcheckRequest();
	spellRequest.setId(jsonReqObject.getString("id"));
	spellRequest.setMethod(jsonReqObject.getString("method"));
	SpellcheckRequestParams params = new SpellcheckRequestParams();
	params.setLang(jsonReqObject.getJSONArray("params").getString(0));
	Object object = jsonReqObject.getJSONArray("params").get(1);
	if( object instanceof String )
	{
		params.setStringList(Collections.singletonList(object.toString()));
	}
	else if( object instanceof JSONArray )
	{
		params.setStringList((JSONArray) object);
	}
	spellRequest.setParams(params);

	SpellcheckResponse spellResponse = spellcheckService.service(spellRequest);

	resp.setHeader("Cache-Control", "no-cache, no-store"); //$NON-NLS-1$//$NON-NLS-2$
	resp.setContentType("application/json"); //$NON-NLS-1$
	resp.getWriter().write(parseResponseToJSON(spellResponse));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:33,代碼來源:SpellcheckServlet.java

示例4: configure

import net.sf.json.JSONObject; //導入方法依賴的package包/類
@Override
public boolean configure(final StaplerRequest req, final JSONObject json) throws FormException {
    Object sqsQueues = json.get("sqsQueues");
    if (json.size() == 1) {
        String key = json.keys().next().toString();
        sqsQueues = json.getJSONObject(key).get("sqsQueues");
    }
    this.sqsQueues = req.bindJSONToList(SQSTriggerQueue.class, sqsQueues);
    this.initQueueMap();

    this.save();

    EventBroker.getInstance().post(new ConfigurationChangedEvent());
    return true;
}
 
開發者ID:riboseinc,項目名稱:aws-codecommit-trigger-plugin,代碼行數:16,代碼來源:SQSTrigger.java

示例5: spiderList

import net.sf.json.JSONObject; //導入方法依賴的package包/類
/**
 * 爬蟲訪問列表,列出最近7天內,最近的100條爬蟲記錄
 */
@RequestMapping("spiderList")
@ResponseBody
public RequestLogItemListVO spiderList(HttpServletRequest request) throws LogException{
	RequestLogItemListVO vo = new RequestLogItemListVO();
	
	//當前10位時間戳
	int currentTime = DateUtil.timeForUnix10();
	String query = "siteid="+getSiteId();
	String spider = null;
	for (int i = 0; i < spiderNameArray.length; i++) {
		if(spider == null){
			spider = spiderNameArray[i];
		}else{
			spider = spider + " or " + spiderNameArray[i];
		}
	}
	query = query + " and ("+spider+")";
	
	//當月訪問量統計
	ArrayList<QueriedLog> jinriQlList = G.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 604800), currentTime, 0, 100, true);
	
	JSONArray jsonArray = new JSONArray();	//某天訪問量,pv
	for (int i = 0; i < jinriQlList.size(); i++) {
		LogItem li = jinriQlList.get(i).GetLogItem();
		JSONObject json = JSONObject.fromObject(li.ToJsonString());
		try {
			json.put("logtimeString", DateUtil.dateFormat(json.getInt("logtime"), "MM-dd HH:mm"));
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
		
		UserAgent ua = UserAgent.parseUserAgentString(json.getString("userAgent"));
		json.put("os", ua.getOperatingSystem());
		json.put("browser", ua.getBrowser());
		if(ua.getOperatingSystem().getName().equals("Unknown")){
			String userAgent = json.getString("userAgent");
			//沒有發現是哪個瀏覽器,那可能是爬蟲
			for (int j = 0; j < spiderNameArray.length; j++) {
				if(userAgent.indexOf(spiderNameArray[j]) > -1){
					json.put("os", spiderExplainArray[j]);
				}
			}
			
			if(json.get("os") == null){
				if(userAgent.equals("Mozilla")){
					//忽略
				}else{
					System.out.println("未發現的useragent : "+json.toString());
				}
			}
		}
		
		jsonArray.add(json);
		
	}
	vo.setList(jsonArray);
	
	AliyunLog.addActionLog(getSiteId(), "獲取最近7天內,最近的100條訪問記錄");
	
	return vo;
}
 
開發者ID:xnx3,項目名稱:wangmarket,代碼行數:65,代碼來源:RequestLogController.java

示例6: getRCJSON

import net.sf.json.JSONObject; //導入方法依賴的package包/類
private JSONObject getRCJSON(String[] rcodes) {
    JSONObject result = new JSONObject();
    for (String rcode : rcodes) {
        int oldval = 0;
        if (result.containsKey(rcode)) {
            oldval = (Integer) result.get(rcode);
        }
        result.put(rcode, oldval + 1);

    }
    return result;
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:13,代碼來源:LoadosophiaClient.java


注:本文中的net.sf.json.JSONObject.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。