List of usage examples for com.google.gwt.json.client JSONNumber JSONNumber
public JSONNumber(double value)
From source file:ccc.client.gwt.core.GWTJson.java
License:Open Source License
/** {@inheritDoc} */ @Override/*from ww w . j a va 2 s. c o m*/ public void set(final String key, final Long value) { _delegate.put(key, (null == value) ? JSONNull.getInstance() : new JSONNumber(value.doubleValue())); }
From source file:client.serializers.JSONSeriesSerializer.java
License:Open Source License
/** * Serialize to JSON./*from www . j ava 2 s. c o m*/ */ @Override public String serialize(SortedSet<Integer> years, List<SeriesManager.Row> rows) { JSONArray array = new JSONArray(); int arrayIndex = 0; for (SeriesManager.Row row : rows) { JSONObject rowObject = new JSONObject(); Series series = row.getSeries(); Country country = series.getCountry(); if (country != null) { rowObject.put(COUNTRY_NAME, new JSONString(country.getName())); rowObject.put(COUNTRY_ISO, new JSONString(country.getISO())); } List<Point> points = series.getPoints(); if (points != null) { for (Point point : points) { rowObject.put(point.getYear() + "", new JSONNumber(((int) (point.getValue() * RES)) / RES)); } } array.set(arrayIndex, rowObject); arrayIndex++; } return array.toString(); }
From source file:client.ui.components.VectorMap.java
License:Open Source License
/** * Get a {@code JavaScriptObject} containing map information as * required by the library.//from ww w. j a va 2 s.c om * * @param data {@code Map} of ISO codes and values. * @return {@code JavaScriptObject} as required by the library. */ private JavaScriptObject dataToJSObject(Map<String, Double> data) { if (data == null) { return null; } JSONObject dataObject = new JSONObject(); for (Map.Entry<String, Double> entry : data.entrySet()) { dataObject.put(entry.getKey(), new JSONNumber(entry.getValue())); } return dataObject.getJavaScriptObject(); }
From source file:colt.json.gwt.client.UJsonClient.java
License:Apache License
static public void add(JSONObject _o, String _key, long _long) { _o.put(_key, new JSONNumber(_long)); }
From source file:colt.json.gwt.client.UJsonClient.java
License:Apache License
static public void add(JSONObject _o, String _key, double _double) { _o.put(_key, new JSONNumber(_double)); }
From source file:com.ait.lienzo.client.core.shape.GridLayer.java
License:Open Source License
@Override public JSONObject toJSONObject() { JSONObject obj = super.toJSONObject(); JSONArray lines = new JSONArray(); JSONArray sizes = new JSONArray(); for (int i = 0; i < 4; i++) { if (m_lines[i] == null) { lines.set(i, JSONNull.getInstance()); } else {// ww w . j av a 2 s . c o m lines.set(i, m_lines[i].toJSONObject()); } sizes.set(i, new JSONNumber(m_sizes[i])); } obj.put("lines", lines); obj.put("sizes", sizes); return obj; }
From source file:com.ait.lienzo.client.core.types.BoundingBox.java
License:Open Source License
public final String toJSONString() { JSONObject object = new JSONObject(); object.put("x", new JSONNumber(getX())); object.put("y", new JSONNumber(getY())); object.put("width", new JSONNumber(getWidth())); object.put("height", new JSONNumber(getHeight())); return object.toString(); }
From source file:com.ait.lienzo.client.core.types.ClipRegion.java
License:Open Source License
public final String toJSONString() { JSONObject object = new JSONObject(); object.put("minX", new JSONNumber(getMinX())); object.put("minY", new JSONNumber(getMinY())); object.put("maxX", new JSONNumber(getMaxX())); object.put("maxY", new JSONNumber(getMaxY())); return object.toString(); }
From source file:com.ait.toolkit.clientio.uploader.client.Configurable.java
License:Apache License
private JSONValue convertToJSONValue(Object value) { if (value == null) { return JSONNull.getInstance(); } else if (value instanceof JSONValue) { return (JSONValue) value; }/* w ww . j a va 2 s .c o m*/ if (value instanceof Boolean) { return JSONBoolean.getInstance((Boolean) value); } else if (value instanceof Number) { return new JSONNumber(((Number) value).doubleValue()); } else if (value instanceof String) { return new JSONString((String) value); } else if (value instanceof JavaScriptObject) { return new JSONObject((JavaScriptObject) value); } else if (value instanceof Configurable) { return ((Configurable) value).getOptions(); } else if (value.getClass().isArray()) { JSONArray jsonArray = new JSONArray(); Object[] valueArray = (Object[]) value; for (int i = 0, valueArrayLength = valueArray.length; i < valueArrayLength; i++) { Object arrayValue = valueArray[i]; jsonArray.set(i, convertToJSONValue(arrayValue)); } return jsonArray; } return null; }
From source file:com.apress.progwt.client.json.JSONWrapper.java
License:Apache License
public void put(String key, int value) { object.put(key, new JSONNumber(value)); }