List of usage examples for org.json JSONArray getInt
public int getInt(int index) throws JSONException
From source file:com.liferay.mobile.android.v62.ddmstructure.DDMStructureService.java
public Integer searchCount(long companyId, JSONArray groupIds, JSONArray classNameIds, String name, String description, String storageType, int type, boolean andOperator) throws Exception { JSONObject _command = new JSONObject(); try {/*from w ww. j a v a 2 s . c o m*/ JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _params.put("groupIds", checkNull(groupIds)); _params.put("classNameIds", checkNull(classNameIds)); _params.put("name", checkNull(name)); _params.put("description", checkNull(description)); _params.put("storageType", checkNull(storageType)); _params.put("type", type); _params.put("andOperator", andOperator); _command.put("/ddmstructure/search-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); }
From source file:net.sylvek.where.FacebookClient.java
public int[] getFriends() throws ClientProtocolException, IOException, NoSuchAlgorithmException, JSONException { StringBuilder params = new StringBuilder(); params.append("api_key=" + API_KEY); params.append("&call_id=" + System.currentTimeMillis()); params.append("&format=" + format); params.append("&method=Friends.get"); params.append("&session_key=" + session); params.append("&v=" + v); params.append("&sig=" + getSig(params, secretGenerated)); String result = postRequest(params.toString()); JSONArray json = new JSONArray(result); int[] friends = new int[json.length()]; for (int i = 0; i < json.length(); i++) { friends[i] = json.getInt(i); }//from www . j av a 2 s . c om return friends; }
From source file:ded.model.Entity.java
public Entity(JSONObject o, int ver) throws JSONException { this.loc = AWTJSONUtil.pointFromJSON(o.getJSONObject("loc")); this.size = AWTJSONUtil.dimensionFromJSON(o.getJSONObject("size")); if (o.has("shape")) { this.shape = EntityShape.valueOf(EntityShape.class, o.getString("shape")); }//from www. j a va 2s .c o m this.name = o.optString("name", ""); this.attributes = o.optString("attributes", ""); JSONArray params = o.optJSONArray("shapeParams"); if (params != null) { this.shapeParams = new int[params.length()]; for (int i = 0; i < params.length(); i++) { this.shapeParams[i] = params.getInt(i); } } JSONArray flags = o.optJSONArray("shapeFlags"); if (flags != null) { this.shapeFlags = AWTJSONUtil.enumSetFromJSON(ShapeFlag.class, flags); } if (ver >= 5) { this.fillColor = o.optString("fillColor", defaultFillColor); } if (ver >= 12) { this.anchorName = o.optString("anchorName", ""); } if (ver >= 7) { this.imageFileName = o.optString("imageFileName", ""); } if (ver >= 8 && o.has("imageFillStyle")) { this.imageFillStyle = ImageFillStyle.valueOf(ImageFillStyle.class, o.getString("imageFillStyle")); } }
From source file:com.dubsar_dictionary.Dubsar.model.Model.java
protected void parsePointers(JSONArray pointers) throws JSONException { mPointers = new HashMap<String, List<List<Object>>>(); mPointerCount = pointers.length();/* w w w . j a v a2 s . c om*/ for (int j = 0; j < pointers.length(); ++j) { JSONArray _pointer = pointers.getJSONArray(j); String ptype = _pointer.getString(0); String targetType = _pointer.getString(1); int targetId = _pointer.getInt(2); String targetText = _pointer.getString(3); String targetGloss = _pointer.getString(4); List<List<Object>> pointersByType = mPointers.get(ptype); if (pointersByType == null) { pointersByType = new ArrayList<List<Object>>(); mPointers.put(ptype, pointersByType); } ArrayList<Object> pointer = new ArrayList<Object>(); pointer.add(targetType); pointer.add(Integer.valueOf(targetId)); pointer.add(targetText); pointer.add(targetGloss); pointersByType.add(pointer); } }
From source file:de.ailis.midi4js.Midi4JS.java
/** * Sends a MIDI message to a receiver.//from w ww . j a va2 s . co m * * @param receiverHandle * The handle of the receiver. * @param jsonMessageStr * Then message encoded as a JSON string * @param timeStamp * The message timestamp * @throws InvalidMidiDataException * When the midi data is invalid. * @throws JSONException * When JSON data could not be parsed. */ public void sendMessage(final int receiverHandle, final String jsonMessageStr, final long timeStamp) throws InvalidMidiDataException, JSONException { final Receiver receiver = resolveReceiverHandle(receiverHandle); final JSONObject json = new JSONObject(jsonMessageStr); final JSONArray jsonData = json.getJSONArray("data"); final int length = jsonData.length(); final byte[] data = new byte[length]; for (int i = 0; i < length; i++) data[i] = (byte) (jsonData.getInt(i) & 0xff); final RawMidiMessage message = new RawMidiMessage(data); receiver.send(message, timeStamp); }
From source file:com.liferay.mobile.android.v7.wikinode.WikiNodeService.java
public Integer getNodesCount(long groupId, int status) throws Exception { JSONObject _command = new JSONObject(); try {//from ww w. jav a2 s. c om JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("status", status); _command.put("/wiki.wikinode/get-nodes-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); }
From source file:com.liferay.mobile.android.v7.wikinode.WikiNodeService.java
public Integer getNodesCount(long groupId) throws Exception { JSONObject _command = new JSONObject(); try {// w ww . j av a 2 s.com JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _command.put("/wiki.wikinode/get-nodes-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); }
From source file:org.ohmage.reminders.notif.NotifDesc.java
public boolean loadString(String desc) { initialze();// w ww . java 2 s. c o m if (desc == null) { return false; } try { //Load the string JSONObject jDesc = new JSONObject(desc); mDuration = jDesc.getInt(KEY_DURATION); mSuppress = jDesc.getInt(KEY_SUPPRESSION); if (jDesc.has(KEY_REPEAT)) { mRepeatList.clear(); JSONArray repeats = jDesc.getJSONArray(KEY_REPEAT); for (int i = 0; i < repeats.length(); i++) { mRepeatList.add(repeats.getInt(i)); } } } catch (JSONException e) { return false; } return true; }
From source file:com.phonegap.CameraLauncher.java
/** * Executes the request and returns PluginResult. * /*from www . j ava 2 s . co m*/ * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackId The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. */ public PluginResult execute(String action, JSONArray args, String callbackId) { PluginResult.Status status = PluginResult.Status.OK; String result = ""; this.callbackId = callbackId; try { if (action.equals("takePicture")) { int destType = DATA_URL; if (args.length() > 1) { destType = args.getInt(1); } int srcType = CAMERA; if (args.length() > 2) { srcType = args.getInt(2); } if (srcType == CAMERA) { this.takePicture(args.getInt(0), destType); } else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { this.getImage(args.getInt(0), srcType, destType); } PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); return r; } return new PluginResult(status, result); } catch (JSONException e) { e.printStackTrace(); return new PluginResult(PluginResult.Status.JSON_EXCEPTION); } }
From source file:net.straylightlabs.archivo.net.MindCommandRecordingSearch.java
private List<Integer> parseEpisodeNumbers(JSONObject json) { JSONArray episodeNums = json.getJSONArray("episodeNum"); List<Integer> episodes = new ArrayList<>(); for (int i = 0; i < episodeNums.length(); i++) { episodes.add(episodeNums.getInt(i)); }/*ww w . ja va 2 s. c o m*/ return episodes; }