com.google.gwt.json.client.JSONParser Java Examples
The following examples show how to use
com.google.gwt.json.client.JSONParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WaitForBuildResultCommand.java From appinventor-extensions with Apache License 2.0 | 6 votes |
private static String extractFormName(RpcResult result) { String extraString = result.getExtra(); if (extraString != null) { JSONValue extraJSONValue = JSONParser.parseStrict(extraString); JSONObject extraJSONObject = extraJSONValue.isObject(); if (extraJSONObject != null) { JSONValue formNameJSONValue = extraJSONObject.get("formName"); if (formNameJSONValue != null) { JSONString formNameJSONString = formNameJSONValue.isString(); if (formNameJSONString != null) { return formNameJSONString.stringValue(); } } } } return "Screen1"; }
Example #2
Source File: BootstrapServerStore.java From core with GNU Lesser General Public License v2.1 | 6 votes |
public BootstrapServer restoreSelection() { if (storage != null) { //noinspection MismatchedQueryAndUpdateOfCollection StorageMap storageMap = new StorageMap(storage); if (storageMap.containsKey(KEY)) { String json = storageMap.get(SELECTED); if (json != null) { JSONValue jsonValue = JSONParser.parseStrict(json); if (jsonValue != null) { JSONObject jsonObject = jsonValue.isObject(); if (jsonObject != null) { AutoBean<BootstrapServer> bean = AutoBeanCodex .decode(factory, BootstrapServer.class, jsonObject.toString()); return bean.as(); } } } } } return null; }
Example #3
Source File: BootstrapServerStore.java From core with GNU Lesser General Public License v2.1 | 6 votes |
public List<BootstrapServer> load() { List<BootstrapServer> servers = new ArrayList<BootstrapServer>(); if (storage != null) { //noinspection MismatchedQueryAndUpdateOfCollection StorageMap storageMap = new StorageMap(storage); if (storageMap.containsKey(KEY)) { String json = storageMap.get(KEY); if (json != null) { JSONValue jsonValue = JSONParser.parseStrict(json); if (jsonValue != null) { JSONArray jsonArray = jsonValue.isArray(); if (jsonArray != null) { for (int i = 0; i < jsonArray.size(); i++) { AutoBean<BootstrapServer> bean = AutoBeanCodex .decode(factory, BootstrapServer.class, jsonArray.get(i).toString()); servers.add(bean.as()); } } } } } } return servers; }
Example #4
Source File: GwtGadgetInfoParser.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
@Override public List<GadgetInfo> parseGadgetInfoJson(String json) { List<GadgetInfo> gadgetList = new ArrayList<GadgetInfo>(); JSONValue value = JSONParser.parseStrict(json); JSONArray array = value.isArray(); if (array != null) { for (int i = 0; i < array.size(); i++) { JSONValue item = array.get(i); GadgetInfo info = parseGadgetInfo(item); if (info != null) { gadgetList.add(info); } } } return gadgetList; }
Example #5
Source File: GwtGadgetInfoParser.java From swellrt with Apache License 2.0 | 6 votes |
@Override public List<GadgetInfo> parseGadgetInfoJson(String json) { List<GadgetInfo> gadgetList = new ArrayList<GadgetInfo>(); JSONValue value = JSONParser.parseStrict(json); JSONArray array = value.isArray(); if (array != null) { for (int i = 0; i < array.size(); i++) { JSONValue item = array.get(i); GadgetInfo info = parseGadgetInfo(item); if (info != null) { gadgetList.add(info); } } } return gadgetList; }
Example #6
Source File: LeafletStyle.java From geowe-core with GNU General Public License v3.0 | 6 votes |
public static ProjectLayerStyle getStyle(String geoJSONCSS) { ProjectLayerStyle style = null; final JSONValue jsonValue = JSONParser.parseLenient(geoJSONCSS); final JSONObject geoJSONCssObject = jsonValue.isObject(); if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) { JSONObject styleObject = geoJSONCssObject .get(GeoJSONCSS.STYLE_NAME).isObject(); String fillColor = getStringValue(styleObject, FILL_COLOR_NAME); Double fillOpacity = getDoubleValue(styleObject, FILL_OPACITY_NAME); if(fillOpacity == null) { fillOpacity = getDoubleValue(styleObject, FILL_OPACITY2_NAME); } String strokeColor = getStringValue(styleObject, STROKE_COLOR_NAME); Double strokeWidth = getDoubleValue(styleObject, STROKE_WIDTH_NAME); style = new ProjectLayerStyle(fillColor, fillOpacity, strokeColor, strokeWidth); } return style; }
Example #7
Source File: UploadResponse.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public ModelNode get() { ModelNode node; if (contentType.startsWith(APPLICATION_DMR_ENCODED)) { node = ModelNode.fromBase64(payload); } else if (contentType.startsWith(APPLICATION_JSON)) { node = new ModelNode(); JSONObject response = JSONParser.parseLenient(payload).isObject(); JSONString outcome = response.get(OUTCOME).isString(); node.get(OUTCOME).set(outcome.stringValue()); if (outcome.stringValue().equals(SUCCESS)) { if (response.containsKey(RESULT) && response.get(RESULT).isObject() != null) { node.get(RESULT).set(stringify(response.get(RESULT).isObject().getJavaScriptObject(), 2)); } else { node.get(RESULT).set(new ModelNode()); } } else { String failure = extractFailure(response); node.get(FAILURE_DESCRIPTION).set(failure); } } else { node = new ModelNode(); node.get(OUTCOME).set(FAILED); node.get(FAILURE_DESCRIPTION).set("Unable to parse response with content-type " + contentType); } return node; }
Example #8
Source File: LoadCompatMatrix.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void execute(Control<BootstrapContext> control) { TextResource compat = TextResources.INSTANCE.compat(); JSONValue root = JSONParser.parseLenient(compat.getText()); JSONObject versionList = root.isObject(); Set<String> keys = versionList.keySet(); for (String key : keys) { modelVersions.put(key, versionList.get(key).isString().stringValue()); } System.out.println("Build against Core Model Version: " + modelVersions.get("core-version")); control.proceed(); }
Example #9
Source File: InputFile.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void handleCompleteJson(String reponseData) { if (Strings.isNullOrEmpty(reponseData)) { handleError("500", "Unable to post data"); } JSONObject jsObject = JSONParser.parseLenient(reponseData).isObject(); final FileDto file = new FileDto(); file.setName(jsObject.get("name").isString().stringValue()); file.setExtension(jsObject.get("extension").isString().stringValue()); file.setMime(jsObject.get("mime").isString().stringValue()); file.setToken(jsObject.get("token").isString().stringValue()); file.setContentLength((long) jsObject.get("contentLength").isNumber().doubleValue()); if (this.uploadForm != null) { this.uploadForm = this.uploadForm.destroy(); } this.sendRequest = null; this.fileId = null; this.progressBar.edit(this.progressBar.getMax()); Scheduler.get().scheduleFixedDelay(new RepeatingCommand() { @Override public boolean execute() { InputFile.this.edit(file); return false; } }, this.params.inputFileProgressHideDelay()); }
Example #10
Source File: GeoJSONCSS.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public VectorStyleDef getLayerStyle(String vectorFormatString) { VectorFeatureStyleDef def = null; final JSONValue jsonValue = JSONParser.parseLenient(vectorFormatString); final JSONObject geoJSONCssObject = jsonValue.isObject(); if (geoJSONCssObject.containsKey(GeoJSONCSS.STYLE_NAME)) { JSONObject styleObject = geoJSONCssObject.get(GeoJSONCSS.STYLE_NAME).isObject(); JSObject styleJSObject = styleObject.getJavaScriptObject().cast(); def = getStyleDef(styleJSObject); } return def; }
Example #11
Source File: Project.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public Project(String json) { final JSONValue jsonValue = JSONParser.parseLenient(json); final JSONObject jsonObject = jsonValue.isObject(); String projectDate = jsonObject.get(DATE_NAME).isString().stringValue(); String projectTitle = jsonObject.get(TITLE_NAME).isString().stringValue(); String projectVersion = jsonObject.get(VERSION_NAME).isString().stringValue(); String projectDescription = jsonObject.get(DESCRIPTION_NAME).isString().stringValue(); setDate(projectDate); setTitle(projectTitle); setVersion(projectVersion); setDescription(projectDescription); JSONArray layersArray = jsonObject.get(VECTORS_NAME).isArray(); if (layersArray != null) { for (int i = 0; i < layersArray.size(); i++) { JSONObject projectLayerObj = layersArray.get(i).isObject(); String name = projectLayerObj.get(NAME).isString().stringValue(); String content = projectLayerObj.get(CONTENT_NAME).isString().stringValue(); JSONObject styleProjectLayer = projectLayerObj.get(STYLE_NAME).isObject(); String fillColor = styleProjectLayer.get(ProjectLayerStyle.FILL_COLOR_NAME).isString().stringValue(); Double fillOpacity = styleProjectLayer.get(ProjectLayerStyle.FILL_OPACITY_NAME).isNumber().doubleValue(); String strokeColor = styleProjectLayer.get(ProjectLayerStyle.STROKE_COLOR_NAME).isString().stringValue(); Double strokeWidth = styleProjectLayer.get(ProjectLayerStyle.STROKE_WIDTH_NAME).isNumber().doubleValue(); add(name, content, fillColor, fillOpacity, strokeColor, strokeWidth); } } }
Example #12
Source File: JsonTokenizer.java From proarc with GNU General Public License v3.0 | 5 votes |
public static JSONValue parse(String token) { try { if (JsonUtils.safeToEval(token)) { JSONValue jsonv = JSONParser.parseStrict(token); return jsonv; } } catch (Exception ex) { LOG.log(Level.SEVERE, token, ex); } return null; }
Example #13
Source File: ErrorHandler.java From proarc with GNU General Public License v3.0 | 5 votes |
/** * Creates response object from JSON response string in * {@link com.smartgwt.client.data.RestDataSource SmartGWT format}. * @param response JSON response string * @return response object */ public static DSResponse getDsResponse(String response) { DSResponse dsResponse; // ClientUtils.info(LOG, "response: %s", response); if (response == null || response.isEmpty()) { // not JSON response LOG.log(Level.WARNING, null, new IllegalStateException("Empty response!")); dsResponse = new DSResponse(); dsResponse.setStatus(RPCResponse.STATUS_SUCCESS); } else { JSONValue rVal = JSONParser.parseStrict(response); if (rVal.isObject() != null) { rVal = rVal.isObject().get("response"); } if (rVal != null && rVal.isObject() != null) { JSONObject rObj = rVal.isObject(); dsResponse = DSResponse.getOrCreateRef(rObj.getJavaScriptObject()); } else { // not JSON response in expected format JSONObject jsonObject = new JSONObject(); jsonObject.put("data", new JSONString(response)); dsResponse = new DSResponse(jsonObject.getJavaScriptObject()); dsResponse.setStatus(RPCResponse.STATUS_FAILURE); } } return dsResponse; }
Example #14
Source File: GWTFileUploadResponse.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * GWTFileUploadResponse * * @param text json encoded parameters. */ public GWTFileUploadResponse(String text) { text = text.substring(text.indexOf("{")); text = text.substring(0, text.lastIndexOf("}") + 1); JSONValue responseValue = JSONParser.parseStrict(text); JSONObject response = responseValue.isObject(); // Deserialize information hasAutomation = response.get("hasAutomation").isBoolean().booleanValue(); path = URL.decodeQueryString(response.get("path").isString().stringValue()); error = response.get("error").isString().stringValue(); showWizardCategories = response.get("showWizardCategories").isBoolean().booleanValue(); showWizardKeywords = response.get("showWizardKeywords").isBoolean().booleanValue(); digitalSignature = response.get("digitalSignature").isBoolean().booleanValue(); // Getting property groups JSONArray groupsArray = response.get("groupsList").isArray(); if (groupsArray != null) { for (int i = 0; i <= groupsArray.size() - 1; i++) { groupsList.add(groupsArray.get(i).isString().stringValue()); } } // Getting workflows JSONArray workflowArray = response.get("workflowList").isArray(); if (workflowArray != null) { for (int i = 0; i <= workflowArray.size() - 1; i++) { workflowList.add(workflowArray.get(i).isString().stringValue()); } } }
Example #15
Source File: BlockSelectorBox.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * getSubsetDrawerNames * @param form * @return array of built-in block drawers for the blocks editor that contain blocks included in * the subset parameter. This keeps empty drawers from displaying in the Blocks Editor */ private Set<String> getSubsetDrawerNames(MockForm form) { String subsetJsonString = form.getPropertyValue(SettingsConstants.YOUNG_ANDROID_SETTINGS_BLOCK_SUBSET); if (subsetJsonString.length() > 0) { JSONObject subsetJSON = JSONParser.parseStrict(subsetJsonString).isObject(); Set<String> subsetDrawers = new HashSet<String>(subsetJSON.get("shownBlockTypes").isObject().keySet()); subsetDrawers.retainAll(BUILTIN_DRAWER_NAMES); return subsetDrawers; } else { return BUILTIN_DRAWER_NAMES; } }
Example #16
Source File: TemplateUploadWizard.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * Returns a list of Template objects containing data needed * to load a template from a zip file. Each non-null template object * is created from its Json string * * @return ArrayList of TemplateInfo objects */ protected static ArrayList<TemplateInfo> getTemplates() { JSONValue jsonVal = JSONParser.parseLenient(templateDataString); JSONArray jsonArr = jsonVal.isArray(); ArrayList<TemplateInfo> templates = new ArrayList<TemplateInfo>(); for (int i = 0; i < jsonArr.size(); i++) { JSONValue value = jsonArr.get(i); JSONObject obj = value.isObject(); if (obj != null) templates.add(new TemplateInfo(obj)); // Create TemplateInfo from Json } return templates; }
Example #17
Source File: TemplateUploadWizard.java From appinventor-extensions with Apache License 2.0 | 5 votes |
/** * Sets the dynamic template Urls from a jsonStr. This method is * called during start up where jsonStr is retrieved from User * settings. * * @param jsonStr */ public static void setStoredTemplateUrls(String jsonStr) { if (jsonStr == null || jsonStr.length() == 0) return; JSONValue jsonVal = JSONParser.parseLenient(jsonStr); JSONArray jsonArr = jsonVal.isArray(); for (int i = 0; i < jsonArr.size(); i++) { JSONValue value = jsonArr.get(i); JSONString str = value.isString(); dynamicTemplateUrls.add(str.stringValue()); } }
Example #18
Source File: GeocodingPanelWidget.java From geowe-core with GNU General Public License v3.0 | 4 votes |
private void getW3WPosition(final String words) { startProgressBar(); w3wServiceAsync.getPosition(words, w3wTool.getLocale(), new AsyncCallback<String>() { public void onFailure(final Throwable caught) { finishProgressBar(); final AlertMessageBox messageBox = new AlertMessageBox(UIMessages.INSTANCE.warning(), UIMessages.INSTANCE.w3wErrorText()); messageBox.show(); } public void onSuccess(final String response) { finishProgressBar(); if (response.isEmpty()) { showException(UIMessages.INSTANCE.w3wErrorText()); return; } final JSONValue jsonValue = JSONParser.parseLenient(response); final JSONObject jsonObject = jsonValue.isObject(); if (jsonObject.containsKey("geometry")) { final JSONObject jsonCoords = jsonObject.get("geometry").isObject(); final double latitud = jsonCoords.get("lat").isNumber().doubleValue(); final double longitud = jsonCoords.get("lng").isNumber().doubleValue(); updateMap(latitud, longitud, 20, "EPSG:4326"); final LonLat lonLat = new LonLat(longitud, latitud); transformToInternalProjection(lonLat, "EPSG:4326"); w3wTool.addElementToW3wLayer(lonLat, words); } else if (jsonObject.containsKey("error")) { showException(UIMessages.INSTANCE.fail() + jsonObject.get("message").toString()); } else { showException(UIMessages.INSTANCE.w3wErrorText()); } } }); }
Example #19
Source File: SubsetJSONPropertyEditor.java From appinventor-extensions with Apache License 2.0 | 4 votes |
public void callLoadGlobalBlocks(String jsonStr) { JSONObject jsonObj = JSONParser.parseStrict(jsonStr).isObject(); INSTANCE.loadComponents(jsonObj); INSTANCE.loadGlobalBlocks(jsonObj); }
Example #20
Source File: BitcoinJSONViewer.java From bitcoin-transaction-explorer with MIT License | 3 votes |
public void setValue(final String json) { final JSONValue tree = JSONParser.parseStrict(json); clear(); display(2, this, tree); }