List of usage examples for com.google.gwt.json.client JSONValue isObject
public JSONObject isObject()
From source file:org.lirazs.gbackbone.client.core.data.OptionsList.java
License:Apache License
public OptionsList(JSONArray array) { for (int i = 0; i < array.size(); i++) { JSONValue value = array.get(i); JSONObject object = value.isObject(); if (object != null) { add(new Options(object)); }/*from ww w. j ava 2 s . com*/ } }
From source file:org.nuxeo.ecm.platform.gwt.client.model.Document.java
License:Open Source License
public JSONValue getProperty(String schema, String property) { JSONValue o1 = json.get(schema); if (o1 != null && o1.isObject() != null) { JSONValue o2 = o1.isObject().get(property); return o2; }/*from w w w . ja v a2 s .c o m*/ return null; }
From source file:org.nuxeo.ecm.platform.gwt.client.model.Document.java
License:Open Source License
public String getDateProperty(String schema, String property) { JSONValue v = getProperty(schema, property); if (v != null && v.isObject() != null) { JSONObject o = v.isObject();//from w w w . j a v a 2 s. c o m JSONValue time = o.get("timeInMillis"); if (time != null && time.isNumber() != null) { Date date = new Date((long) time.isNumber().doubleValue()); return date.toString(); } } return null; }
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();/*from w w w.j a v a 2 s .co m*/ if (ar != null) { json = ar.get(0); } Document doc = new Document(json.isObject()); openDocument(doc); }
From source file:org.onebusaway.webapp.gwt.common.rpc.JsonLibrary.java
License:Apache License
public static JSONObject getJsonObj(JSONObject object, String key) { JSONValue value = object.get(key); if (value == null) return null; return value.isObject(); }
From source file:org.onebusaway.webapp.gwt.notification.NotificationStateDAO.java
License:Apache License
private NotificationStateNode getJSONValueAsNode(JSONValue entryValue) { JSONObject object = entryValue.isObject(); if (object == null) return null; NotificationStateNode node = new NotificationStateNode(); String stopId = JsonLibrary.getJsonString(object, KEY_ID); if (stopId == null) return null; node.setStopId(stopId);/* ww w.j ava2 s . c om*/ Double index = JsonLibrary.getJsonDouble(object, KEY_INDEX); if (index == null) return null; node.setIndex(index.intValue()); JSONObject stateObject = JsonLibrary.getJsonObj(object, KEY_STATE); if (stateObject == null) return null; NotificationState state = getJSONObjectAsState(stateObject); if (state == null) return null; node.setState(state); return node; }
From source file:org.onebusaway.webapp.gwt.notification.NotificationStateDAO.java
License:Apache License
private NotificationState getJSONObjectAsState(JSONObject object) { NotificationState state = new NotificationState(); Double minutesBefore = JsonLibrary.getJsonDouble(object, KEY_MINUTES_BEFORE); if (minutesBefore == null) return null; state.setMinutesBefore(minutesBefore.intValue()); JSONArray jsonArray = JsonLibrary.getJsonArray(object, KEY_METHODS); if (jsonArray != null) { for (int i = 0; i < jsonArray.size(); i++) { JSONValue value = jsonArray.get(i); JSONObject methodObject = value.isObject(); if (methodObject != null) { NotificationMethodState methodState = getJSONObjectAsMethodState(methodObject); if (methodState != null) state.getMethodStates().add(methodState); }/*from w w w .j a v a 2 s . c o m*/ } } return state; }
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"); }/* w w w .j a va 2s . c o 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; }
From source file:org.opennms.features.gwt.combobox.client.rest.NodeRestResponseMapper.java
License:Open Source License
public static List<NodeDetail> mapNodeJSONtoNodeDetail(final String jsonString) { final List<NodeDetail> nodeDetails = new ArrayList<NodeDetail>(); final JSONValue value = JSONParser.parseStrict(jsonString); final JSONObject obj = value.isObject(); final JSONArray arr = value.isArray(); JsArray<NodeDetail> jsDetails = null; if (obj != null) { jsDetails = createNodeDetailsArray(obj.getJavaScriptObject()); } else if (arr != null) { jsDetails = createNodeDetailsArray(arr.getJavaScriptObject()); } else {/* w w w . j av a2s .c om*/ doLog(jsonString + " does not parse as an array or object!", value); } if (jsDetails != null) { for (int i = 0; i < jsDetails.length(); i++) { if (!jsDetails.get(i).getNodeType().equals("D")) { nodeDetails.add(jsDetails.get(i)); } } } return nodeDetails; }
From source file:org.opennms.features.gwt.ksc.add.client.KscReportRestResponseMapper.java
License:Open Source License
public static List<KscReport> translate(final String jsonText) { final List<KscReport> reports = new ArrayList<KscReport>(); final JSONValue value = JSONParser.parseStrict(jsonText); final JSONArray arr = value.isArray(); final JSONObject obj = value.isObject(); JsArray<KscReport> jsReports = null; if (obj != null) { jsReports = translateJsonReportList(obj.getJavaScriptObject()); } else if (arr != null) { jsReports = translateJsonReportList(arr.getJavaScriptObject()); } else {/*ww w . j ava2 s . c o m*/ doLog(jsonText + " did not parse as an object or array!", value); } if (jsReports != null) { for (int i = 0; i < jsReports.length(); i++) { reports.add(jsReports.get(i)); } } doLog("KSC reports:", reports); return reports; }