当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.getInt方法代码示例

本文整理汇总了Java中org.json.JSONObject.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getInt方法的具体用法?Java JSONObject.getInt怎么用?Java JSONObject.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseJson

import org.json.JSONObject; //导入方法依赖的package包/类
public  ArrayList<ProblemData> parseJson() throws JSONException {
    ArrayList<ProblemData> data = new ArrayList<>();
    JSONObject jsonObject  = jsondata;
   JSONObject res = jsonObject.getJSONObject("result");
   JSONArray problems = res.getJSONArray("problems");
    JSONArray stats = res.getJSONArray("problemStatistics");
    for(int i=0; i< stats.length() && i<20;i++){
        JSONObject nxtprob = problems.getJSONObject(i);
        JSONObject probstat = stats.getJSONObject(i);
        int id  = nxtprob.getInt("contestId");
        String idx = nxtprob.getString("index");
        String name = nxtprob.getString("name");
        int solvecnt = probstat.getInt("solvedCount");
        ProblemData dat = new ProblemData(id,idx,name,solvecnt);
        data.add(dat);


    }

    return data;
}
 
开发者ID:mkfeuhrer,项目名称:CodeMania,代码行数:22,代码来源:parser.java

示例2: parseErrorMsg

import org.json.JSONObject; //导入方法依赖的package包/类
private ParserResponse parseErrorMsg(JSONObject msg, int id) {
    try {
        JSONObject error = msg.getJSONObject("error");
        int code = error.getInt("code");
        String errMsg = error.getString("message");
        String description = "";
        if (error.has("description")) {
            description = error.getString("description");
        }
        String errLog = "Error for req #" + id + ", code " + code
                + ": " + errMsg + "; " + description;
        if (notCriticalError(code)) {
            // We can recover from the error, retry connection
            return new ParserResponse(Action.RECONNECT, errLog);
        } else {
            return shutDownAction(errLog);
        }
    } catch (JSONException ex) {
        return shutDownAction("Error in HitBTC error parsing:"
                + ex.getMessage());
    }
}
 
开发者ID:prog-fun,项目名称:exchange-apis,代码行数:23,代码来源:HitBtcParser.java

示例3: ImportControl

import org.json.JSONObject; //导入方法依赖的package包/类
public ImportControl(String path) {
    String json = Utils.readFile(path);
    if (json != null && !json.isEmpty()) {
        try {
            JSONObject main = new JSONObject(json);
            mVersion = main.getInt("version");
            JSONObject control = main.getJSONObject("control");

            String id = control.getString("id");
            if (id != null) {
                Items.Control controlItem = Items.Control.getControl(id);
                if (controlItem != null) {
                    ArrayList<Items.Setting> settings = Items.getSettings(controlItem);
                    for (Items.Setting setting : settings) {
                        if (setting.isRequired() && !control.has(setting.getId())) {
                            control = null;
                            break;
                        }
                    }
                }
                mControlJSON = control;
            }
        } catch (JSONException ignored) {
        }
    }
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:27,代码来源:ImportControl.java

示例4: getDesk

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void getDesk(JSONObject result) {

    try {
        JSONArray desks = result.getJSONArray("baskets");
        for (int i=0; i<desks.length(); i++){
            JSONObject desk = (JSONObject) desks.get(i);
            name = desk.getString("name");
            image = desk.getString("image");
            piece = desk.getInt("piece");
            price = desk.getDouble("total");
            basketID = desk.getInt("basketID");

            product = new Product(piece, name, image, price, basketID);
            productList.add(product);

        }

        deskOrderAdapter = new DeskOrderAdapter(this, productList);
        lvBasket.setAdapter(deskOrderAdapter);

    } catch (JSONException e) {
        e.printStackTrace();
    }

}
 
开发者ID:yusufcakal,项目名称:RestaurantApp,代码行数:27,代码来源:DeskBasketActivity.java

示例5: parseFromHTTPResponse

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public SmsSingleSenderResult parseFromHTTPResponse(HTTPResponse response)
        throws JSONException {

    JSONObject json = parseToJson(response);

    result = json.getInt("result");
    errMsg = json.getString("errmsg");

    if (result == 0) {
        ext = json.getString("ext");
        sid = json.getString("sid");
        fee = json.getInt("fee");
    }

    return this;
}
 
开发者ID:qcloudsms,项目名称:qcloudsms_java,代码行数:18,代码来源:SmsSingleSenderResult.java

示例6: getUserFilesTree

import org.json.JSONObject; //导入方法依赖的package包/类
public static void getUserFilesTree(JSONObject jsonObject, JSONObject jsonObject2,
                                    Set<Long> fileIdSet) throws Exception {
    if (jsonObject.getInt("folder") == 1) {
        JSONArray jsonArray = jsonObject.getJSONArray("children");
        for (int i=0; i<jsonArray.length(); i++) {
            JSONObject origin = (JSONObject) jsonArray.get(i);
            if (origin.getInt("folder") == 0) {
                if (!fileIdSet.contains(origin.getLong("id"))) continue;
            }

            JSONObject jsonObject1 = new JSONObject();
            // copy..
            copyNode(origin, jsonObject1);
            jsonObject2.getJSONArray("children").put(jsonObject1);
            getUserFilesTree(origin, jsonObject1, fileIdSet);
        }

    }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:20,代码来源:TreeFilter.java

示例7: getURLsFromPage

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document page) {
    List<String> urls = new ArrayList<>();
    String html = page.data();
    if (!html.contains("episodeList : ")) {
        logger.error("No 'episodeList' found at " + this.url);
        return urls;
    }
    String jsonString = Utils.between(html, "episodeList : ", ",\n").get(0);
    JSONArray json = new JSONArray(jsonString);
    for (int i = 0; i < json.length(); i++) {
        JSONObject obj = json.getJSONObject(i);
        TapasticEpisode episode = new TapasticEpisode(i, obj.getInt("id"), obj.getString("title"));
        episodes.add(episode);
        urls.add("http://tapastic.com/episode/" + episode.id);
    }
    return urls;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:19,代码来源:TapasticRipper.java

示例8: dispatchEvent

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void dispatchEvent(JSONObject json, int sequence) {
    MessageChannel channel = (MessageChannel) identity.getMessageChannel(json.getString("channel_id"));
    User user = (User) identity.getUser(json.getString("user_id"));
    int timeStamp = json.getInt("timestamp");

    dispatchEvent(new TypingStartEvent(identity, sequence, channel, user, timeStamp));
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:9,代码来源:TypingStartEventHandler.java

示例9: moveto

import org.json.JSONObject; //导入方法依赖的package包/类
public void moveto(JSONObject query, JSONObject uriParams, Session session) {
    IJavaElement element = null;
    if (query.has("element")) {
        element = session.findElement(query.getString("element"));
    }
    boolean hasOffset = query.has("xoffset");
    if (hasOffset != query.has("yoffset")) {
        throw new MissingCommandParametersException("Missing x-offset or y-offset. Provide both x and y offsets.", null);
    }
    if (element == null && !hasOffset) {
        throw new MissingCommandParametersException("One of the element or offset is expected.", null);
    }
    int xoffset, yoffset;
    if (hasOffset) {
        xoffset = query.getInt("xoffset");
        yoffset = query.getInt("yoffset");
    } else {
        Point p = element.getMidpoint();
        xoffset = p.x;
        yoffset = p.y;
    }
    if (element == null) {
        if (hasOffset && lastComponenet.element != null) {
            element = lastComponenet.element;
            xoffset += lastComponenet.x;
            yoffset += lastComponenet.y;
        } else {
            element = session.getActiveElement();
        }
    }
    element.moveto(xoffset, yoffset);
    lastComponenet.x = xoffset;
    lastComponenet.y = yoffset;
    lastComponenet.element = element;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:JavaServer.java

示例10: getIntegerIgnoreErrors

import org.json.JSONObject; //导入方法依赖的package包/类
protected static int getIntegerIgnoreErrors(String attribute, JSONObject source,
                                            int defaultValue) {
  if (source.has(attribute)) {
    try {
      return source.getInt(attribute);
    } catch (final JSONException ex) {
      LOG.error("problem getting attribute", ex);
    }
  }
  return defaultValue;
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:12,代码来源:JsonUtil.java

示例11: update

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * force a update by a blocking get
 * @return true if it was successful, false if not
 */
public Boolean update() {
	CoapResponse resp = gateway.get("/15005/" + this.group.getGroupID() + "/" + this.moodID);
	
	if(!ResponseCode.isSuccess(resp.getCode())) {
		System.out.println("Mood update for " + this.moodID + "failed!");
		return false;
	}else {
		try {
			JSONObject json = new JSONObject(resp.getResponseText());
			
			//name
			if(json.has("9001")) {
				this.name = json.getString("9001");
			}
			
			//createdAt
			if(json.has("9002")) {
				this.createdAt = json.getInt("9002");
			}
			
			return true;
		}catch(Exception e) {
			System.out.println("Unexpected response: " + e.getMessage()); 
			return false;
		}
	}
}
 
开发者ID:peterkappelt,项目名称:JTradfri,代码行数:32,代码来源:TradfriMood.java

示例12: getIntFromJson

import org.json.JSONObject; //导入方法依赖的package包/类
public static Integer getIntFromJson(JSONObject newsItemJson, String key){
    try{
        int value = newsItemJson.getInt(key);
        return value;
    }catch(JSONException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:mariabecker,项目名称:OldNews,代码行数:10,代码来源:JsonUtils.java

示例13: onComplete

import org.json.JSONObject; //导入方法依赖的package包/类
public void onComplete(Object obj) {
    Object obj2 = null;
    if (obj != null) {
        JSONObject jSONObject = (JSONObject) obj;
        if (jSONObject != null) {
            String string;
            Object obj3;
            Object obj4;
            String str = "";
            try {
                if (jSONObject.getInt("sendinstall") == 1) {
                    obj2 = 1;
                }
                string = jSONObject.getString("installwording");
                obj3 = obj2;
            } catch (JSONException e) {
                obj4 = null;
                f.d("FeedConfirm", "There is no value for sendinstall.");
                String str2 = str;
                obj3 = obj4;
                string = str2;
            }
            obj4 = URLDecoder.decode(string);
            f.b("TAG", " WORDING = " + obj4 + "xx");
            if (obj3 != null && !TextUtils.isEmpty(obj4)) {
                a(obj4, this.a, obj);
            } else if (this.a != null) {
                this.a.onComplete(obj);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:AuthAgent.java

示例14: generateAccessToken

import org.json.JSONObject; //导入方法依赖的package包/类
private void generateAccessToken() throws JSONException, IOException {
	String url = String.format("https://www.deviantart.com/oauth2/token?client_id=%s&client_secret=%s&grant_type=client_credentials",
			APIKeys.get(APIKey.DEVIANTART_CLIENT_ID),
			APIKeys.get(APIKey.DEVIANTART_API_SECRET));
	JSONObject oauthObj = new JSONObject(NetUtils.getBody(url));
	this.accessToken = oauthObj.getString("access_token");
	this.expiresIn = oauthObj.getInt("expires_in");
	this.lastTokenGeneration = System.currentTimeMillis();
	LogUtils.infof("DeviantArt token generated: %s", this.accessToken);
}
 
开发者ID:Shadorc,项目名称:Shadbot,代码行数:11,代码来源:ImageCmd.java

示例15: buildGame

import org.json.JSONObject; //导入方法依赖的package包/类
public Game buildGame(JSONObject json) {
    JSONObject gameJson = json.getJSONObject("game");
    String name = gameJson.isNull("name") ? null : gameJson.getString("name");
    String url = gameJson.has("type") && gameJson.getInt("type") == IGame.Type.STREAMING.key ?
            gameJson.getString("url") : null;
    return new Game(identity, name, url);
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:8,代码来源:ObjectBuilder.java


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