本文整理匯總了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;
}
示例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());
}
}
示例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) {
}
}
}
示例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();
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}