List of usage examples for com.google.gwt.json.client JSONValue isArray
public JSONArray isArray()
From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java
License:Apache License
private Object fromJsonValue(JSONValue elem) { if (elem.isString() != null) { return elem.isString().stringValue(); } else if (elem.isNumber() != null) { return elem.isNumber().doubleValue(); } else if (elem.isArray() != null) { return asList(elem.isArray()); } else if (elem.isNull() != null) { return null; } else if (elem.isObject() != null) { return asMap(elem.isObject()); } else {// w w w . ja va2s. co m return ""; } }
From source file:org.jbpm.formbuilder.client.JsonLoadInput.java
License:Apache License
private static Object asActualValue(JSONValue value) { if (value.isArray() != null) { JSONArray arr = value.isArray(); List<Object> retval = new ArrayList<Object>(); for (int index = 0; index < arr.size(); index++) { JSONValue subValue = arr.get(index); retval.add(asActualValue(subValue)); }/*from ww w. ja va2s.c o m*/ return retval; } else if (value.isBoolean() != null) { return String.valueOf(value.isBoolean().booleanValue()); } else if (value.isNull() != null) { return null; } else if (value.isNumber() != null) { return String.valueOf(value.isNumber().doubleValue()); } else if (value.isString() != null) { return value.isString().stringValue(); } else if (value.isObject() != null) { return toFormData(value.isObject()); } return null; }
From source file:org.lirazs.gbackbone.client.core.collection.Collection.java
License:Apache License
public List<T> parse(JSONValue resp, Options options) { List<T> result = new ArrayList<T>(); JSONArray array = resp != null && resp.isArray() != null ? resp.isArray() : new JSONArray(); if (resp != null && resp.isObject() != null) { array.set(0, resp.isObject());// ww w .jav a 2 s.c om } if (options == null) options = new Options(); for (int i = 0; i < array.size(); i++) { JSONValue jsonValue = array.get(i); if (jsonValue != null && jsonValue.isObject() != null) { T model = prepareModel(jsonValue.isObject(), options); if (model != null) { result.add(model); } } } return result; }
From source file:org.moxieapps.gwt.highcharts.client.BaseChart.java
License:Apache License
protected JSONObject convertSeriesToJSON(Series series) { JSONObject seriesOptions = series.getOptions(); if (seriesOptions == null) { seriesOptions = new JSONObject(); }/*from ww w.j a va 2s . c o m*/ JSONValue dataValue = seriesOptions.get("data"); if (dataValue == null || dataValue.isArray() == null) { seriesOptions.put("data", new JSONArray()); } copyPointsToJSONArray(series.getPoints(), (JSONArray) seriesOptions.get("data")); return seriesOptions; }
From source file:org.nuxeo.ecm.platform.gwt.client.model.GetDocument.java
License:Open Source License
@Override public void onSuccess(HttpResponse response) { JSONValue json = response.asJSON(); json = json.isObject().get("response").isObject().get("data"); JSONArray ar = json.isArray(); if (ar != null) { json = ar.get(0);//from ww w .j a v a2 s . co m } Document doc = new Document(json.isObject()); openDocument(doc); }
From source file:org.nuxeo.ecm.platform.gwt.client.model.JSONWrapper.java
License:Open Source License
protected String[] getStringArray(JSONObject obj, String key) { if (obj != null) { JSONValue value = obj.get(key); if (value != null && value.isArray() != null) { JSONArray array = value.isArray(); int size = array.size(); String[] ret = new String[size]; for (int i = 0; i < size; i++) { JSONValue v = array.get(i); if (v != null && v.isString() != null) { ret[i] = v.isString().stringValue(); } else { ret[i] = ""; }/* www . ja v a2s . c o m*/ } return ret; } } return null; }
From source file:org.onebusaway.webapp.gwt.common.rpc.JsonLibrary.java
License:Apache License
public static JSONArray getJsonArray(JSONObject object, String key) { JSONValue value = object.get(key); if (value == null) return null; return value.isArray(); }
From source file:org.onebusaway.webapp.gwt.notification.NotificationStateDAO.java
License:Apache License
private List<NotificationStateNode> loadState() { List<NotificationStateNode> nodes = new ArrayList<NotificationStateNode>(); String cookieValue = Cookies.getCookie(COOKIE_NAME); if (cookieValue != null) { System.out.println("loading=" + cookieValue); JSONValue p = JSONParser.parse(cookieValue); JSONArray array = p.isArray(); if (array != null) { for (int i = 0; i < array.size(); i++) { JSONValue entryValue = array.get(i); NotificationStateNode node = getJSONValueAsNode(entryValue); if (node != null) nodes.add(node);/*from w w w .j a v a 2 s . c o m*/ } } } return nodes; }
From source file:org.opencms.ui.client.CmsSingleFileUploadDialog.java
License:Open Source License
/** * Parses the upload response of the server and decides what to do.<p> * * @param results a JSON Object/* ww w . ja v a 2s. c o m*/ */ @SuppressWarnings("null") public void parseResponse(String results) { cancelUpdateProgress(); stopLoadingAnimation(); if ((!m_canceled) && CmsStringUtil.isNotEmptyOrWhitespaceOnly(results)) { JSONObject jsonObject = JSONParser.parseStrict(results).isObject(); boolean success = jsonObject.get(I_CmsUploadConstants.KEY_SUCCESS).isBoolean().booleanValue(); // If the upload is done so fast that we did not receive any progress information, then // the content length is unknown. For that reason take the request size to show how // much bytes were uploaded. double size = jsonObject.get(I_CmsUploadConstants.KEY_REQUEST_SIZE).isNumber().doubleValue(); long requestSize = new Double(size).longValue(); if (m_contentLength == 0) { m_contentLength = requestSize; } if (success) { m_mainPanel.displayDialogInfo(Messages.get().key(Messages.GUI_UPLOAD_INFO_FINISHING_0), false); m_progressInfo.finish(); JSONValue uploadedFilesVal = jsonObject.get(I_CmsUploadConstants.KEY_UPLOADED_FILE_NAMES); if (uploadedFilesVal != null) { JSONArray uploadedFilesArray = uploadedFilesVal.isArray(); if (uploadedFilesArray != null) { List<String> uploadedFiles = new ArrayList<String>(); if (uploadedFilesArray != null) { for (int i = 0; i < uploadedFilesArray.size(); i++) { JSONString entry = uploadedFilesArray.get(i).isString(); if (entry != null) { uploadedFiles.add(entry.stringValue()); } } } if (m_context != null) { m_context.onUploadFinished(uploadedFiles); } } } closeOnSuccess(); } else { String message = jsonObject.get(I_CmsUploadConstants.KEY_MESSAGE).isString().stringValue(); String stacktrace = jsonObject.get(I_CmsUploadConstants.KEY_STACKTRACE).isString().stringValue(); showErrorReport(message, stacktrace); } } }
From source file:org.openehealth.ipf.platform.camel.flow.admin.client.JSONUtil.java
License:Apache License
public static List<Map<String, ?>> toMapList(JSONValue jsonArray) { JSONArray array = jsonArray.isArray(); if (array == null) { throw new AssertionError("JSON value is not an array"); }//from ww w . j a va 2 s . co m List<Map<String, ?>> list = new ArrayList<Map<String, ?>>(); for (int idx = 0; idx < array.size(); ++idx) { JSONValue jsonValue = array.get(idx); JSONObject jsonObject = jsonValue.isObject(); if (jsonObject == null) { throw new AssertionError("JSON value is not an object"); } Map<String, Object> map = new HashMap<String, Object>(); for (String key : jsonObject.keySet()) { JSONValue value = jsonObject.get(key); map.put(key, value); } list.add(map); } return list; }