com.google.gwt.json.client.JSONNumber Java Examples
The following examples show how to use
com.google.gwt.json.client.JSONNumber.
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: Application.java From SensorWebClient with GNU General Public License v2.0 | 6 votes |
private static TimeseriesRenderingOptions createRenderingOptions(String options) { if (options == null) { return new TimeseriesRenderingOptions(); } TimeseriesRenderingOptions tsOptions = new TimeseriesRenderingOptions(); JSONObject tsRenderingOptions = new JSONObject(parseUntrustedJson(options)); if (tsRenderingOptions.containsKey("color")) { JSONString color = tsRenderingOptions.get("color").isString(); tsOptions.setColor(color.stringValue()); } if (tsRenderingOptions.containsKey("lineWidth")) { JSONNumber lineWidth = tsRenderingOptions.get("lineWidth").isNumber(); tsOptions.setLineWidth((int)lineWidth.doubleValue()); } return tsOptions; }
Example #2
Source File: JSONUtil.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * toJson * */ public static JSONObject toJson(Object obj) { JSONObject json = new JSONObject(); if (obj instanceof GWTQueryParams) { GWTQueryParams params = (GWTQueryParams) obj; json.put("author", new JSONString(params.getAuthor())); json.put("keywords", new JSONString(params.getKeywords())); json.put("content", new JSONString(params.getContent())); json.put("name", new JSONString(params.getName())); json.put("path", new JSONString(URL.encodeQueryString(params.getPath()))); json.put("mimeType", new JSONString(params.getMimeType())); json.put("domain", new JSONNumber(params.getDomain())); json.put("mailFrom", new JSONString(params.getMailFrom())); json.put("mailTo", new JSONString(params.getMailTo())); json.put("mailSubject", new JSONString(params.getMailSubject())); json.put("categoryUuid", new JSONString(params.getCategoryUuid())); json.put("categoryPath", new JSONString(URL.encodeQueryString(params.getCategoryPath()))); json.put("operator", new JSONString(params.getOperator())); if (params.getLastModifiedFrom() != null) { json.put("lastModifiedFrom", new JSONString(ISO8601.formatBasic(params.getLastModifiedFrom()))); } if (params.getLastModifiedTo() != null) { json.put("lastModifiedTo", new JSONString(ISO8601.formatBasic(params.getLastModifiedTo()))); } if (!params.getProperties().isEmpty()) { JSONObject properties = new JSONObject(); for (String key : params.getProperties().keySet()) { GWTPropertyParams propertyParam = params.getProperties().get(key); JSONObject property = new JSONObject(); // Only is necessary groupName and value property.put("grpName", new JSONString(propertyParam.getGrpName())); property.put("value", new JSONString(propertyParam.getValue())); properties.put(key, property); } json.put("properties", properties); } } return json; }
Example #3
Source File: ProjectLayerStyle.java From geowe-core with GNU General Public License v3.0 | 5 votes |
public JSONObject getJSONObject() { JSONObject projectLayerObject = new JSONObject(); projectLayerObject.put(FILL_COLOR_NAME, new JSONString(getFillColor())); projectLayerObject.put(FILL_OPACITY_NAME, new JSONNumber(getFillOpacity())); projectLayerObject.put(STROKE_COLOR_NAME, new JSONString(getStrokeColor())); projectLayerObject.put(STROKE_WIDTH_NAME, new JSONNumber(getStrokeWidth())); return projectLayerObject; }
Example #4
Source File: GadgetMetadata.java From swellrt with Apache License 2.0 | 5 votes |
/** * Helper function to extract a long value from given JSON object. * * @param json JSON object to extract the value from. * @param key key of the value to extract. * @return the Long object extracted from JSON (can be null if the value does * not exist or is invalid. */ private static Long getJsonLongValue(JSONObject json, String key) { JSONValue value = json.get(key); JSONNumber number = (value == null) ? null : value.isNumber(); if (number != null) { return Math.round(number.doubleValue()); } else { return null; } }
Example #5
Source File: GadgetMetadata.java From incubator-retired-wave with Apache License 2.0 | 5 votes |
/** * Helper function to extract a long value from given JSON object. * * @param json JSON object to extract the value from. * @param key key of the value to extract. * @return the Long object extracted from JSON (can be null if the value does * not exist or is invalid. */ private static Long getJsonLongValue(JSONObject json, String key) { JSONValue value = json.get(key); JSONNumber number = (value == null) ? null : value.isNumber(); if (number != null) { return Math.round(number.doubleValue()); } else { return null; } }