List of usage examples for com.google.gson JsonArray iterator
public Iterator<JsonElement> iterator()
From source file:com.google.dart.server.internal.remote.processor.JsonProcessor.java
License:Open Source License
/** * Given some {@link JsonArray} and of string primitives, return the {@link String} array. * //from www . j a va2 s.c o m * @param strJsonArray some {@link JsonArray} of {@link String}s * @return the {@link String} array */ protected String[] constructStringArray(JsonArray strJsonArray) { if (strJsonArray == null) { return StringUtilities.EMPTY_ARRAY; } List<String> strings = Lists.newArrayList(); Iterator<JsonElement> iterator = strJsonArray.iterator(); while (iterator.hasNext()) { strings.add(iterator.next().getAsString()); } return strings.toArray(new String[strings.size()]); }
From source file:com.google.dart.server.utilities.general.JsonUtilities.java
License:Open Source License
public static Boolean[] decodeBooleanArray(JsonArray jsonArray) { if (jsonArray == null) { return new Boolean[0]; }/*from w w w. j av a2 s . co m*/ int i = 0; Boolean[] booleanArray = new Boolean[jsonArray.size()]; Iterator<JsonElement> iterator = jsonArray.iterator(); while (iterator.hasNext()) { booleanArray[i] = iterator.next().getAsBoolean(); i++; } return booleanArray; }
From source file:com.google.dart.server.utilities.general.JsonUtilities.java
License:Open Source License
public static int[] decodeIntArray(JsonArray jsonArray) { if (jsonArray == null) { return new int[0]; }/* w w w .ja v a2s. c om*/ int i = 0; int[] intArray = new int[jsonArray.size()]; Iterator<JsonElement> iterator = jsonArray.iterator(); while (iterator.hasNext()) { intArray[i] = iterator.next().getAsInt(); i++; } return intArray; }
From source file:com.google.dart.server.utilities.general.JsonUtilities.java
License:Open Source License
public static Integer[] decodeIntegerArray(JsonArray jsonArray) { if (jsonArray == null) { return new Integer[0]; }//from w w w .j av a 2s.c o m int i = 0; Integer[] intArray = new Integer[jsonArray.size()]; Iterator<JsonElement> iterator = jsonArray.iterator(); while (iterator.hasNext()) { intArray[i] = iterator.next().getAsInt(); i++; } return intArray; }
From source file:com.google.dart.server.utilities.general.JsonUtilities.java
License:Open Source License
public static List<String> decodeStringList(JsonArray jsonArray) { if (jsonArray == null) { return StringUtilities.EMPTY_LIST; }/*from w w w . j av a 2s. com*/ List<String> stringList = new ArrayList<String>(jsonArray.size()); Iterator<JsonElement> iterator = jsonArray.iterator(); while (iterator.hasNext()) { stringList.add(iterator.next().getAsString()); } return stringList; }
From source file:com.google.iosched.model.DataExtractor.java
License:Open Source License
public JsonObject extractFromDataSources(JsonDataSources sources) { usedTags = new HashSet<String>(); usedSpeakers = new HashSet<String>(); JsonObject result = new JsonObject(); result.add(OutputJsonKeys.MainTypes.rooms.name(), extractRooms(sources)); JsonArray speakers = extractSpeakers(sources); JsonArray tags = extractTags(sources); result.add(OutputJsonKeys.MainTypes.video_library.name(), extractVideoSessions(sources)); result.add(OutputJsonKeys.MainTypes.sessions.name(), extractSessions(sources)); // Remove tags that are not used on any session (b/14419126) Iterator<JsonElement> tagsIt = tags.iterator(); while (tagsIt.hasNext()) { JsonElement tag = tagsIt.next(); String tagName = get(tag.getAsJsonObject(), OutputJsonKeys.Tags.tag).getAsString(); if (!usedTags.contains(tagName)) { tagsIt.remove();//w w w . j a v a 2s . c o m } } // Remove speakers that are not used on any session: Iterator<JsonElement> it = speakers.iterator(); while (it.hasNext()) { JsonElement el = it.next(); String id = get(el.getAsJsonObject(), OutputJsonKeys.Speakers.id).getAsString(); if (!usedSpeakers.contains(id)) { it.remove(); } } result.add(OutputJsonKeys.MainTypes.speakers.name(), speakers); result.add(OutputJsonKeys.MainTypes.tags.name(), tags); return result; }
From source file:com.graphiq.kettle.jobentries.slack.SlackBotDialog.java
License:Apache License
/** * This method is called by Spoon when the user opens the settings dialog of the job entry. * It should open the dialog and return only once the dialog has been closed by the user. * * If the user confirms the dialog, the meta object (passed in the constructor) must * be updated to reflect the new job entry settings. The changed flag of the meta object must * reflect whether the job entry configuration was changed by the dialog. * * If the user cancels the dialog, the meta object must not be updated, and its changed flag * must remain unaltered./*from www . j a v a 2s . c om*/ * * The open() method must return the met object of the job entry after the user has confirmed the dialog, * or null if the user cancelled the dialog. */ public JobEntryInterface open() { // SWT code for setting up the dialog Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell(parent, props.getJobsDialogStyle()); props.setLook(shell); JobDialog.setShellImage(shell, meta); // save the job entry's changed flag changed = meta.hasChanged(); // The ModifyListener used on all controls. It will update the meta object to // indicate that changes are being made. ModifyListener lsMod = new ModifyListener() { public void modifyText(ModifyEvent e) { meta.setChanged(); } }; // ------------------------------------------------------- // // SWT code for building the actual settings dialog // // ------------------------------------------------------- // FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(PKG, "SlackBot.Shell.Title") + SlackBotDialog.STEP_VERSION); int middle = props.getMiddlePct(); int margin = Const.MARGIN; //Start building UI elements // Job entry name line Label wlName = new Label(shell, SWT.RIGHT); wlName.setText(BaseMessages.getString(PKG, "SlackBot.StepNameLabel")); props.setLook(wlName); FormData fdlName = new FormData(); fdlName.left = new FormAttachment(0, 0); fdlName.right = new FormAttachment(middle, 0); fdlName.top = new FormAttachment(0, margin); wlName.setLayoutData(fdlName); wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wName); wName.addModifyListener(lsMod); FormData fdName = new FormData(); fdName.left = new FormAttachment(middle, 0); fdName.top = new FormAttachment(0, margin); fdName.right = new FormAttachment(100, 0); wName.setLayoutData(fdName); // Separator Line Label separator1 = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR); FormData fdSeparator1 = new FormData(); fdSeparator1.left = new FormAttachment(0, margin); fdSeparator1.top = new FormAttachment(wlName, margin * 3); fdSeparator1.right = new FormAttachment(100, 0); separator1.setLayoutData(fdSeparator1); props.setLook(separator1); selectionAdapter = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { meta.setChanged(); } }; /* * Recipient Group */ recipientGroup = new Group(shell, SWT.SHADOW_NONE); recipientGroup.setText(BaseMessages.getString(PKG, "SlackBot.MessageSettings")); props.setLook(recipientGroup); recipientGroupForm = new FormData(); recipientGroupForm.left = new FormAttachment(0, 0); recipientGroupForm.right = new FormAttachment(100, 0); recipientGroupForm.top = new FormAttachment(separator1, margin * 2); GridLayout recipientGrid = new GridLayout(); recipientGrid.numColumns = 2; recipientGroup.setLayout(recipientGrid); recipientGroup.setLayoutData(recipientGroupForm); // token wlToken = new Label(recipientGroup, SWT.RIGHT); wlToken.setText(BaseMessages.getString(PKG, "SlackBot.Token")); wlToken.setToolTipText(BaseMessages.getString(PKG, "SlackBot.TokenTip")); fdlToken = new GridData(); fdlToken.horizontalAlignment = GridData.END; wlToken.setLayoutData(fdlToken); wToken = new TextVar(jobMeta, recipientGroup, SWT.SINGLE | SWT.LEFT); props.setLook(wToken); wToken.addModifyListener(lsMod); fdToken = new GridData(); fdToken.horizontalAlignment = GridData.FILL; fdToken.grabExcessHorizontalSpace = true; wToken.setLayoutData(fdToken); /* * channel update button */ wlUpdate = new Label(recipientGroup, SWT.RIGHT); wlUpdate.setText(BaseMessages.getString(PKG, "SlackBot.UpdateChannel")); wlUpdate.setToolTipText(BaseMessages.getString(PKG, "SlackBot.UpdateChannelTip")); fdlUpdate = new GridData(); fdlUpdate.horizontalAlignment = GridData.END; wlUpdate.setLayoutData(fdlUpdate); wUpdate = new Button(recipientGroup, SWT.PUSH); wUpdate.setText("Update"); fdUpdate = new GridData(); fdUpdate.horizontalAlignment = GridData.FILL; fdUpdate.grabExcessHorizontalSpace = true; wUpdate.setLayoutData(fdUpdate); // post type wlPostType = new Label(recipientGroup, SWT.RIGHT); wlPostType.setText(BaseMessages.getString(PKG, "SlackBot.PostType")); wlPostType.setToolTipText(BaseMessages.getString(PKG, "SlackBot.PostTypeTip")); fdlPostType = new GridData(); fdlPostType.horizontalAlignment = GridData.FILL; wlPostType.setLayoutData(fdlPostType); wPostType = new CCombo(recipientGroup, SWT.READ_ONLY); props.setLook(wPostType); wPostType.addModifyListener(lsMod); fdPostType = new GridData(); fdPostType.horizontalAlignment = GridData.FILL; fdPostType.grabExcessHorizontalSpace = true; wPostType.setLayoutData(fdPostType); wPostType.add("Channel"); wPostType.add("Group"); // room name drop down wlChannel = new Label(recipientGroup, SWT.RIGHT); wlChannel.setText(BaseMessages.getString(PKG, "SlackBot.RoomName")); wlChannel.setToolTipText(BaseMessages.getString(PKG, "SlackBot.RoomNameTip")); fdlChannel = new GridData(); fdlChannel.horizontalAlignment = GridData.FILL; wlChannel.setLayoutData(fdlChannel); wChannel = new CCombo(recipientGroup, SWT.DROP_DOWN); props.setLook(wChannel); wChannel.addModifyListener(lsMod); fdChannel = new GridData(); fdChannel.horizontalAlignment = GridData.FILL; fdChannel.grabExcessHorizontalSpace = true; wChannel.setLayoutData(fdChannel); // Bot Name wlBotName = new Label(recipientGroup, SWT.RIGHT); wlBotName.setText(BaseMessages.getString(PKG, "SlackBot.BotName")); wlBotName.setToolTipText(BaseMessages.getString(PKG, "SlackBot.BotNameTip")); fdlBotName = new GridData(); fdlBotName.horizontalAlignment = GridData.END; wlBotName.setLayoutData(fdlBotName); wBotName = new TextVar(jobMeta, recipientGroup, SWT.SINGLE | SWT.LEFT); props.setLook(wBotName); wBotName.addModifyListener(lsMod); fdBotName = new GridData(); fdBotName.horizontalAlignment = GridData.FILL; fdBotName.grabExcessHorizontalSpace = true; wBotName.setLayoutData(fdBotName); // bot icon drop down wlBotIcon = new Label(recipientGroup, SWT.RIGHT); wlBotIcon.setText(BaseMessages.getString(PKG, "SlackBot.BotIcon")); wlBotIcon.setToolTipText(BaseMessages.getString(PKG, "SlackBot.BotIconTip")); fdlBotIcon = new GridData(); fdlBotIcon.horizontalAlignment = GridData.FILL; wlBotIcon.setLayoutData(fdlBotIcon); wBotIcon = new CCombo(recipientGroup, SWT.DROP_DOWN); props.setLook(wBotIcon); wBotIcon.addModifyListener(lsMod); fdBotIcon = new GridData(); fdBotIcon.horizontalAlignment = GridData.FILL; fdBotIcon.grabExcessHorizontalSpace = true; wBotIcon.setLayoutData(fdBotIcon); /* * Message section */ contentGroup = new Group(shell, SWT.SHADOW_NONE); contentGroup.setText(BaseMessages.getString(PKG, "SlackBot.Message")); props.setLook(contentGroup); contentGroupForm = new FormData(); contentGroupForm.left = new FormAttachment(0, 0); contentGroupForm.right = new FormAttachment(100, 0); contentGroupForm.top = new FormAttachment(recipientGroup, margin * 3); FormLayout contentLayout = new FormLayout(); contentGroup.setLayout(contentLayout); contentGroup.setLayoutData(contentGroupForm); Composite textComposite = new Composite(contentGroup, SWT.NONE); FormLayout textCompositeLayout = new FormLayout(); textCompositeLayoutForm = new FormData(); textCompositeLayoutForm.left = new FormAttachment(0, 0); textCompositeLayoutForm.right = new FormAttachment(100, 0); textCompositeLayoutForm.top = new FormAttachment(0, margin); textComposite.setLayout(textCompositeLayout); textComposite.setLayoutData(textCompositeLayoutForm); standardSuccessButton = new Button(contentGroup, SWT.RADIO); standardSuccessButton.setSelection(false); standardSuccessButton.setSize(100, standardSuccessButton.getSize().y); standardSuccessButtonForm = new FormData(); standardSuccessButtonForm.left = new FormAttachment(0, 0); standardSuccessButtonForm.right = new FormAttachment(10, 0); standardSuccessButtonForm.top = new FormAttachment(0, margin + 2); standardSuccessButton.setLayoutData(standardSuccessButtonForm); standardSuccessLabel = new Label(contentGroup, SWT.LEFT); standardSuccessLabel.setText(BaseMessages.getString(PKG, "SlackBot.Success")); standardSuccessLabel.setToolTipText(BaseMessages.getString(PKG, "SlackBot.StandardSuccess")); standardSuccessLabelForm = new FormData(); standardSuccessLabelForm.left = new FormAttachment(10, 0); standardSuccessLabelForm.right = new FormAttachment(100, 0); standardSuccessLabelForm.top = new FormAttachment(0, margin + 2); standardSuccessLabel.setLayoutData(standardSuccessLabelForm); standardFailureButton = new Button(contentGroup, SWT.RADIO); standardFailureButton.setSelection(true); standardFailureButton.setSize(100, standardFailureButton.getSize().y); standardFailureButtonForm = new FormData(); standardFailureButtonForm.left = new FormAttachment(0, 0); standardFailureButtonForm.right = new FormAttachment(10, 0); standardFailureButtonForm.top = new FormAttachment(standardSuccessLabel, margin); standardFailureButton.setLayoutData(standardFailureButtonForm); standardFailureLabel = new Label(contentGroup, SWT.LEFT); standardFailureLabel.setText(BaseMessages.getString(PKG, "SlackBot.Failure")); standardFailureLabel.setToolTipText(BaseMessages.getString(PKG, "SlackBot.StandardFailure")); standardFailureLabelForm = new FormData(); standardFailureLabelForm.left = new FormAttachment(10, 0); standardFailureLabelForm.right = new FormAttachment(100, 0); standardFailureLabelForm.top = new FormAttachment(standardSuccessLabel, margin); standardFailureLabel.setLayoutData(standardFailureLabelForm); customMessageButton = new Button(contentGroup, SWT.RADIO); customMessageButton.setSelection(false); customMessageButton.setSize(100, customMessageButton.getSize().y); customMessageButtonForm = new FormData(); customMessageButtonForm.left = new FormAttachment(0, 0); customMessageButtonForm.right = new FormAttachment(10, 0); customMessageButtonForm.top = new FormAttachment(standardFailureLabel, margin); customMessageButton.setLayoutData(customMessageButtonForm); Listener lsCustom = new Listener() { public void handleEvent(Event e) { setDialogStatus(true); } }; Listener lsStock = new Listener() { public void handleEvent(Event e) { setDialogStatus(false); } }; customMessageButton.addListener(SWT.Selection, lsCustom); customMessageButton.addSelectionListener(selectionAdapter); standardFailureButton.addListener(SWT.Selection, lsStock); standardFailureButton.addSelectionListener(selectionAdapter); standardSuccessButton.addListener(SWT.Selection, lsStock); standardSuccessButton.addSelectionListener(selectionAdapter); wUpdate.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { try { List<String> vars = jobMeta.getUsedVariables(); SlackConnection slack = new SlackConnection(meta.environmentSubstitute(wToken.getText())); if (!slack.getAuthStatus()) { throw new ConnectException(BaseMessages.getString(PKG, "SlackBot.ConnectionError")); } int roomType; String listName; if (wPostType.getText() == null) { roomType = SlackConnection.CHANNEL; listName = "channels"; } else if (wPostType.getText().equals("Group")) { roomType = SlackConnection.GROUP; listName = "groups"; } else { roomType = SlackConnection.CHANNEL; listName = "channels"; } String result = slack.getRoomList(roomType); JsonElement parsed = new JsonParser().parse(result); JsonObject jObject = parsed.getAsJsonObject(); String status = jObject.get("ok").toString(); if (!status.equals("true")) { new ConnectException(BaseMessages.getString(PKG, "SlackBot.ConnectionErrorList")); } JsonArray jarray = jObject.getAsJsonArray(listName); List<String> options = new LinkedList<String>(); Iterator<JsonElement> jelement = jarray.iterator(); while (jelement.hasNext()) { options.add(jelement.next().getAsJsonObject().get("name").getAsString()); } wChannel.setItems(options.toArray(new String[options.size()])); } catch (Exception ex) { MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); mb.setText(BaseMessages.getString(PKG, "SlackBot.ConnectionError.Title")); mb.setMessage(BaseMessages.getString(PKG, "SlackBot.ConnectionError.Message")); mb.open(); } } }); customMessageLabel = new Label(contentGroup, SWT.LEFT); customMessageLabel.setText(BaseMessages.getString(PKG, "SlackBot.Custom")); customMessageLabel.setToolTipText(BaseMessages.getString(PKG, "SlackBot.CustomTip")); customMessageLabelForm = new FormData(); customMessageLabelForm.left = new FormAttachment(10, 0); customMessageLabelForm.right = new FormAttachment(100, 0); customMessageLabelForm.top = new FormAttachment(standardFailureLabel, margin); customMessageLabel.setLayoutData(customMessageLabelForm); // Separator Line between checkboxes and custom message input Label separator2 = new Label(contentGroup, SWT.HORIZONTAL | SWT.SEPARATOR); FormData fdSeparator2 = new FormData(); fdSeparator2.left = new FormAttachment(0, margin); fdSeparator2.top = new FormAttachment(customMessageLabel, margin); fdSeparator2.right = new FormAttachment(100, 0); separator2.setLayoutData(fdSeparator2); props.setLook(separator2); customTextLabel = new Label(contentGroup, SWT.LEFT); customTextLabel.setText(BaseMessages.getString(PKG, "SlackBot.CustomMsgLabel")); customTextLabelForm = new FormData(); customTextLabelForm.left = new FormAttachment(0, 0); customTextLabelForm.right = new FormAttachment(100, 0); customTextLabelForm.top = new FormAttachment(separator2, margin); customTextLabel.setLayoutData(customTextLabelForm); customTextInput = new Text(contentGroup, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); props.setLook(customTextInput); customTextInput.addModifyListener(lsMod); customTextInputForm = new FormData(); customTextInputForm.left = new FormAttachment(0, 0); customTextInputForm.right = new FormAttachment(100, 0); customTextInputForm.top = new FormAttachment(customTextLabel, margin); customTextInputForm.bottom = new FormAttachment(customTextLabel, 150); customTextInput.setLayoutData(customTextInputForm); customTextInput.addKeyListener(new ControlSpaceKeyAdapter(jobMeta, customTextInput)); /* * Ok and Cancel buttons */ Button wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); Button wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); // at the bottom BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, null); // Add listeners Listener lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; Listener lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; wCancel.addListener(SWT.Selection, lsCancel); wOK.addListener(SWT.Selection, lsOK); // default listener (for hitting "enter") SelectionAdapter lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wName.addSelectionListener(lsDef); // Detect X or ALT-F4 or something that kills this window and cancel the dialog properly shell.addShellListener(new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); // populate the dialog with the values from the meta object populateDialog(); // restore the changed flag to original value, as the modify listeners fire during dialog population meta.setChanged(changed); // restore dialog size and placement, or set default size if none saved yet BaseStepDialog.setSize(shell, 100, 100, false); // open dialog and enter event loop shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } // at this point the dialog has closed, so either ok() or cancel() have been executed return meta; }
From source file:com.gst.infrastructure.core.data.DataValidatorBuilder.java
License:Apache License
public DataValidatorBuilder jsonArrayNotEmpty() { if (this.value == null && this.ignoreNullValue) { return this; }/* w w w .ja v a 2 s.c o m*/ final JsonArray array = (JsonArray) this.value; if (this.value != null && !array.iterator().hasNext()) { final StringBuilder validationErrorCode = new StringBuilder("validation.msg.").append(this.resource) .append(".").append(this.parameter).append(".cannot.be.empty"); final StringBuilder defaultEnglishMessage = new StringBuilder("The parameter ").append(this.parameter) .append(" cannot be empty. You must select at least one."); final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode.toString(), defaultEnglishMessage.toString(), this.parameter); this.dataValidationErrors.add(error); } return this; }
From source file:com.helion3.safeguard.util.DataUtil.java
License:MIT License
/** * Convert JSON to a DataContainer.//w w w . j av a 2 s. co m * @param json JsonObject * @return DataContainer */ public static DataContainer jsonToDataContainer(JsonObject json) { DataContainer result = new MemoryDataContainer(); for (Entry<String, JsonElement> entry : json.entrySet()) { DataQuery keyQuery = DataQuery.of(entry.getKey()); Object object = entry.getValue(); if (object instanceof JsonObject) { result.set(keyQuery, jsonToDataContainer((JsonObject) object)); } else if (object instanceof JsonArray) { JsonArray array = (JsonArray) object; Iterator<JsonElement> iterator = array.iterator(); List<Object> list = new ArrayList<Object>(); while (iterator.hasNext()) { Object child = iterator.next(); if (child instanceof JsonPrimitive) { JsonPrimitive primitive = (JsonPrimitive) child; if (primitive.isString()) { list.add(primitive.getAsString()); } else if (primitive.isNumber()) { // @todo may be wrong format. how do we handle? list.add(primitive.getAsInt()); } else if (primitive.isBoolean()) { list.add(primitive.getAsBoolean()); } else { SafeGuard.getLogger() .error("Unhandled list JsonPrimitive data type: " + primitive.toString()); } } } result.set(keyQuery, list); } else { if (object instanceof JsonPrimitive) { JsonPrimitive primitive = (JsonPrimitive) object; if (primitive.isString()) { result.set(keyQuery, primitive.getAsString()); } else if (primitive.isNumber()) { // @todo may be wrong format. how do we handle? result.set(keyQuery, primitive.getAsInt()); } else if (primitive.isBoolean()) { result.set(keyQuery, primitive.getAsBoolean()); } else { SafeGuard.getLogger().error("Unhandled JsonPrimitive data type: " + primitive.toString()); } } } } return result; }
From source file:com.ibm.iotf.sample.client.application.api.SampleBulkAPIOperations.java
License:Open Source License
/** * This sample showcases how to delete an array of devices. * /* ww w .j a v a2 s . co m*/ * Json Format to delete the device * [ * { * "typeId": "string", * "deviceId": "string" * } * ] * @throws Exception */ private void deleteDevices() throws IoTFCReSTException { System.out.println("Deleting couple of devices"); JsonElement device1 = new JsonParser().parse(deviceToBeDeleted1); JsonElement device2 = new JsonParser().parse(deviceToBeDeleted2); JsonArray arryOfDevicesToBeDeleted = new JsonArray(); arryOfDevicesToBeDeleted.add(device1); arryOfDevicesToBeDeleted.add(device2); try { JsonArray devices = this.apiClient.deleteMultipleDevices(arryOfDevicesToBeDeleted); for (Iterator<JsonElement> iterator = devices.iterator(); iterator.hasNext();) { JsonElement deviceElement = iterator.next(); JsonObject responseJson = deviceElement.getAsJsonObject(); System.out.println(responseJson); } } catch (IoTFCReSTException e) { System.out.println("HttpCode :" + e.getHttpCode() + " ErrorMessage :: " + e.getMessage()); // Print if there is a partial response System.out.println(e.getResponse()); } }