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


Java JSONArray.getInt方法代码示例

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


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

示例1: defaultsToMap

import org.json.JSONArray; //导入方法依赖的package包/类
private static Map<String, Object> defaultsToMap(JSONObject object) throws JSONException {
    final Map<String, Object> map = new HashMap<String, Object>();

    for (Iterator<String> keys = object.keys(); keys.hasNext(); ) {
        String key = keys.next();
        Object value = object.get(key);

        if (value instanceof Integer) {
            // setDefaults() takes Longs
            value = Long.valueOf((Integer) value);
        } else if (value instanceof JSONArray) {
            JSONArray array = (JSONArray) value;
            if (array.length() == 1 && array.get(0) instanceof String) {
                //parse byte[] as Base64 String
                value = Base64.decode(array.getString(0), Base64.DEFAULT);
            } else {
                //parse byte[] as numeric array
                byte[] bytes = new byte[array.length()];
                for (int i = 0; i < array.length(); i++)
                    bytes[i] = (byte) array.getInt(i);
                value = bytes;
            }
        }

        map.put(key, value);
    }
    return map;
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:29,代码来源:RemoteConfigComponent.java

示例2: setSilenceTime

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 * 设置通知静默时间
 * http://docs.jpush.io/client/android_api/#api_5
 */
public static void setSilenceTime(JSONArray data, CallbackContext callbackContext) {
  try {
    int startHour = data.getInt(0);
    int startMinute = data.getInt(1);
    int endHour = data.getInt(2);
    int endMinute = data.getInt(3);
    if (!isValidHour(startHour) || !isValidMinute(startMinute)) {
      callbackContext.error("开始时间数值错误");
      return;
    }
    if (!isValidHour(endHour) || !isValidMinute(endMinute)) {
      callbackContext.error("结束时间数值错误");
      return;
    }
    JPushInterface.setSilenceTime(NXTPushPlugin.getActivity(), startHour, startMinute,
      endHour, endMinute);
  } catch (JSONException e) {
    e.printStackTrace();
    callbackContext.error("error: reading json data.");
  }
}
 
开发者ID:pengkobe,项目名称:nxtpush-cordova-plugin,代码行数:26,代码来源:JPushUtil.java

示例3: setLatestNotificationNum

import org.json.JSONArray; //导入方法依赖的package包/类
/**
 * 设置最新通知数目
 */
public static void setLatestNotificationNum(JSONArray data, CallbackContext callbackContext) {
  int num = -1;
  try {
    num = data.getInt(0);
  } catch (JSONException e) {
    e.printStackTrace();
    callbackContext.error("error reading num json");
  }
  if (num != -1) {
    JPushInterface.setLatestNotificationNumber(
      cordovaCxt, num);
  } else {
    callbackContext.error("error num");
  }
}
 
开发者ID:pengkobe,项目名称:nxtpush-cordova-plugin,代码行数:19,代码来源:JPushUtil.java

示例4: getIntArray

import org.json.JSONArray; //导入方法依赖的package包/类
private Integer[] getIntArray(JSONObject jsonObject, String key) {
    try {
        JSONArray array = jsonObject.getJSONArray(key);
        Integer[] integers = new Integer[array.length()];
        for (int i = 0; i < integers.length; i++) {
            integers[i] = array.getInt(i);
        }
        return integers;
    } catch (JSONException ignored) {
        return null;
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:13,代码来源:CPUFreq.java

示例5: ripVideos

import org.json.JSONArray; //导入方法依赖的package包/类
private void ripVideos() throws IOException {
    String oid = getGID(this.url).replace("videos", "");
    String u = "http://vk.com/al_video.php";
    Map<String,String> postData = new HashMap<>();
    postData.put("al", "1");
    postData.put("act", "load_videos_silent");
    postData.put("offset", "0");
    postData.put("oid", oid);
    Document doc = Http.url(u)
                       .referrer(this.url)
                       .ignoreContentType()
                       .data(postData)
                       .post();
    String[] jsonStrings = doc.toString().split("<!>");
    JSONObject json = new JSONObject(jsonStrings[jsonStrings.length - 1]);
    JSONArray videos = json.getJSONArray("all");
    logger.info("Found " + videos.length() + " videos");
    for (int i = 0; i < videos.length(); i++) {
        JSONArray jsonVideo = videos.getJSONArray(i);
        int vidid = jsonVideo.getInt(1);
        String videoURL = com.rarchives.ripme.ripper.rippers.video.VkRipper.getVideoURLAtPage(
                "http://vk.com/video" + oid + "_" + vidid);
        String prefix = "";
        if (Utils.getConfigBoolean("download.save_order", true)) {
            prefix = String.format("%03d_", i + 1);
        }
        addURLToDownload(new URL(videoURL), prefix);
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            logger.error("Interrupted while waiting to fetch next video URL", e);
            break;
        }
    }
    waitForThreads();
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:37,代码来源:VkRipper.java

示例6: jsonToByteArray

import org.json.JSONArray; //导入方法依赖的package包/类
static byte[] jsonToByteArray(JSONArray json) throws JSONException {
    byte[] b = new byte[json.length()];
    for (int i = 0; i < json.length(); i++) {
        b[i] = (byte) json.getInt(i);
    }
    return b;
}
 
开发者ID:whitedogg13,项目名称:react-native-nfc-manager,代码行数:8,代码来源:Util.java

示例7: getCellRows

import org.json.JSONArray; //导入方法依赖的package包/类
public int[] getCellRows(JSONObject rowObject) {
    JSONArray x = (JSONArray) rowObject.get("rows");
    int[] rows = new int[x.length()];
    for (int i = 0; i < x.length(); i++) {
        rows[i] = x.getInt(i);
    }
    return rows;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:JavaFXElementPropertyAccessor.java

示例8: getSelectedRows

import org.json.JSONArray; //导入方法依赖的package包/类
public int[] getSelectedRows(String value) {
    JSONArray x = (JSONArray) new JSONObject(value).get("rows");
    int[] rows = new int[x.length()];
    for (int i = 0; i < x.length(); i++) {
        rows[i] = x.getInt(i);
    }
    return rows;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:JavaFXElementPropertyAccessor.java

示例9: parseYears

import org.json.JSONArray; //导入方法依赖的package包/类
private static List<Integer> parseYears(JSONArray jArray) throws JSONException {
    List<Integer> years = new ArrayList<>();
    for (int i = 0; i < jArray.length(); i++) {
        int year = jArray.getInt(i);
        years.add(year);
    }
    return years;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:9,代码来源:DiarySync.java

示例10: DeviceInfo

import org.json.JSONArray; //导入方法依赖的package包/类
public DeviceInfo(JSONObject json) {
    try {
        mAndroidVersion = json.getString("android_version");
        mKernelVersion = json.getString("kernel_version");
        mAppVersion = json.getString("app_version");
        mBoard = json.getString("board");
        mModel = json.getString("model");
        mVendor = json.getString("vendor");
        mCpuInfo = json.getString("cpuinfo");
        mFingerprint = json.getString("fingerprint");

        JSONArray commands = json.getJSONArray("commands");
        mCommands = new ArrayList<>();

        for (int i = 0; i < commands.length(); i++) {
            mCommands.add(commands.getString(i));
        }

        JSONArray times = json.getJSONArray("times");
        for (int i = 0; i < times.length(); i++) {
            mAverageSOT += times.getInt(i);
        }
        mAverageSOT /= times.length();
        mAverageSOT *= 100;

        mCpu = json.getLong("cpu");
        mScore = Math.round(json.getDouble("score"));
    } catch (JSONException ignored) {
        mValid = false;
    }
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:32,代码来源:DeviceInfo.java

示例11: getGroups

import org.json.JSONArray; //导入方法依赖的package包/类
public static String getGroups(GWConnection gateway) {
	CoapResponse resp = gateway.get("/15004");
	if(!ResponseCode.isSuccess(resp.getCode())) {
		System.out.println("Get groups failed!");
		return "";
	}else {
		try {
			JSONArray groupIDs = new JSONArray(resp.getResponseText());
			JSONArray returnJSON = new JSONArray();
			
			for(int i = 0; i < groupIDs.length(); i++) {
				int currentID = groupIDs.getInt(i);

				gateway.group(currentID).update();
				
				JSONObject currentKey = new JSONObject();
				currentKey.put("groupid", gateway.group(currentID).getGroupID());
				currentKey.put("name", gateway.group(currentID).getName());
				
				returnJSON.put(currentKey);
			}
			
			return returnJSON.toString();
		}catch(Exception e) {
			System.out.println("Unexpected response: " + e.getMessage());
			return "";
		}
	}
}
 
开发者ID:peterkappelt,项目名称:JTradfri,代码行数:30,代码来源:TradfriGroup.java

示例12: getIntArray

import org.json.JSONArray; //导入方法依赖的package包/类
public int[] getIntArray( String key ) {
	try {
		JSONArray array = data.getJSONArray( key );
		int length = array.length();
		int[] result = new int[length];
		for (int i=0; i < length; i++) {
			result[i] = array.getInt( i );
		}
		return result;
	} catch (JSONException e) {
		reportException(e);
		return null;
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:15,代码来源:Bundle.java

示例13: getDevices

import org.json.JSONArray; //导入方法依赖的package包/类
public static String getDevices(GWConnection gateway) {
	CoapResponse resp = gateway.get("/15001");
	if(!ResponseCode.isSuccess(resp.getCode())) {
		System.out.println("Get devices failed!");
		return "";
	}else {
		try {
			JSONArray deviceIDs = new JSONArray(resp.getResponseText());
			JSONArray returnJSON = new JSONArray();
			
			for(int i = 0; i < deviceIDs.length(); i++) {
				int currentID = deviceIDs.getInt(i);

				gateway.device(currentID).update();
				
				JSONObject currentKey = new JSONObject();
				currentKey.put("deviceid", gateway.device(currentID).getDeviceID());
				currentKey.put("name", gateway.device(currentID).getName());
				
				returnJSON.put(currentKey);
			}
			
			return returnJSON.toString();
		}catch(Exception e) {
			System.out.println("Unexpected response: " + e.getMessage());
			return "";
		}
	}
}
 
开发者ID:peterkappelt,项目名称:JTradfri,代码行数:30,代码来源:TradfriDevice.java

示例14: parseSwitchFaceJson

import org.json.JSONArray; //导入方法依赖的package包/类
public static SwitchFaceInfo parseSwitchFaceJson(String paramString)
        throws JSONException {
    SwitchFaceInfo localSwitchFaceInfo = new SwitchFaceInfo();
    JSONObject localJSONObject = new JSONObject(paramString);

    localSwitchFaceInfo.bP = localJSONObject.getString("tips");
    localSwitchFaceInfo.bQ = localJSONObject.optInt("soundPlayMode");
    localSwitchFaceInfo.bS = localJSONObject.optString("audio");
    localSwitchFaceInfo.cw = localJSONObject.getInt("count");
    localSwitchFaceInfo.cv = new ArrayList();

    JSONArray localJSONArray1 = localJSONObject.getJSONArray("reslist");
    localSwitchFaceInfo.bR = new String[localJSONArray1.length()];
    for (int i = 0; i < localJSONArray1.length(); i++) {
        localSwitchFaceInfo.bR[i] = localJSONArray1.getString(i);
    }
    JSONArray localJSONArray2 = localJSONObject.getJSONArray("pointIndexArray");
    for (int j = 0; j < localJSONArray2.length(); j++) {
        if (j < localSwitchFaceInfo.cw) {
            JSONArray localJSONArray3 = localJSONArray2.getJSONArray(j);
            for (int k = 0; k < localJSONArray3.length(); k++) {
                SwitchFaceInfo.a locala = new SwitchFaceInfo.a();
                locala.cx = j;
                locala.cy = localJSONArray3.getInt(k);
                localSwitchFaceInfo.cv.add(locala);
            }
        }
    }
    return localSwitchFaceInfo;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:31,代码来源:FilterFactory.java

示例15: parseDecorateFaceJson

import org.json.JSONArray; //导入方法依赖的package包/类
public static DecorateFaceBean parseDecorateFaceJson(String paramString)
        throws JSONException {
    DecorateFaceBean locala = new DecorateFaceBean();
    JSONObject localJSONObject = new JSONObject(paramString);

    locala.bP = localJSONObject.getString("tips");
    locala.cw = localJSONObject.getInt("count");
    locala.cv = new ArrayList();

    JSONArray localJSONArray1 = localJSONObject.getJSONArray("reslist");
    locala.bR = new String[localJSONArray1.length()];
    for (int i = 0; i < localJSONArray1.length(); i++) {
        locala.bR[i] = localJSONArray1.getString(i);
    }
    JSONArray localJSONArray2 = localJSONObject.getJSONArray("pointIndexArray");
    for (int j = 0; j < localJSONArray2.length(); j++) {
        if (j < locala.cw) {
            JSONArray localJSONArray3 = localJSONArray2.getJSONArray(j);
            for (int k = 0; k < localJSONArray3.length(); k++) {
                DecorateFaceBean.a locala1 = new DecorateFaceBean.a();
                locala1.cx = j;
                locala1.cy = localJSONArray3.getInt(k);
                locala.cv.add(locala1);
            }
        }
    }
    return locala;
}
 
开发者ID:zhangyaqiang,项目名称:Fatigue-Detection,代码行数:29,代码来源:FilterFactory.java


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