List of usage examples for com.google.gwt.json.client JSONValue toString
@Override public abstract String toString();
From source file:org.jboss.errai.enterprise.client.jaxrs.JacksonTransformer.java
License:Apache License
/** * Transforms Jackson generated JSON into Errai compatible JSON. * /*from ww w . j a va 2s . co m*/ * @param jackson * JSON generated by Jackson * @return Errai compatible JSON */ public static String fromJackson(String jackson) { JSONValue val = JSONParser.parseStrict(jackson); val = fromJackson(val, null, null, new int[1]); return val.toString(); }
From source file:org.jbpm.console.ng.gc.forms.client.display.displayers.util.JSNIHelper.java
License:Apache License
public Map<String, String> parseParams(JSONObject jsonParams) { Map<String, String> params = new HashMap<String, String>(); for (String key : jsonParams.keySet()) { JSONValue value = jsonParams.get(key); if (value != null) { if (value.isString() != null) params.put(key, value.isString().stringValue()); else/* w w w. j ava2 s . c om*/ params.put(key, value.toString()); } } return params; }
From source file:org.jbpm.workbench.forms.client.display.util.JSNIHelper.java
License:Apache License
public Map<String, String> parseParams(JSONObject jsonParams) { Map<String, String> params = new HashMap<String, String>(); for (String key : jsonParams.keySet()) { JSONValue value = jsonParams.get(key); if (value != null) { if (value.isString() != null) { params.put(key, value.isString().stringValue()); } else { params.put(key, value.toString()); }//from w w w . j a va 2 s. co m } } return params; }
From source file:org.nuxeo.ecm.platform.gwt.client.http.HttpRequest.java
License:Open Source License
public HttpRequest setRequestData(JSONValue value) { builder.setRequestData(value.toString()); return this; }
From source file:org.nuxeo.ecm.platform.gwt.client.model.DocumentRef.java
License:Open Source License
public static DocumentRef fromJSON(JSONObject json) { DocumentRef doc = new DocumentRef(); JSONValue val = json.get("id"); if (val != null) { doc.id = val.toString(); }/*from w w w .j av a 2 s . com*/ val = json.get("title"); if (val != null) { doc.title = val.toString(); } val = json.get("type"); if (val != null) { doc.type = val.toString(); } val = json.get("parentId"); if (val != null) { doc.parentId = val.toString(); } val = json.get("name"); if (val != null) { doc.name = val.toString(); } val = json.get("isFolder"); if (val != null) { JSONBoolean b = val.isBoolean(); doc.isFolder = b != null ? b.booleanValue() : false; } return doc; }
From source file:org.openremote.client.shell.ShellEmbeddedPresenter.java
License:Open Source License
public ShellEmbeddedPresenter(ShellEmbeddedView view) { super(view);//from w ww . ja v a2 s.c o m // Catch all events from presenters, publish serializable events on the native WebView bridge catchAllRegistration = addListener(event -> { JSONValue eventValue = EVENT_CODEC.encode(event); // If we can't encode it, it shouldn't be send on the native bridge by definition if (eventValue != null) { LOG.debug("Publishing on embedded shell message bus: " + event.getType()); getView().publishShellEvent(eventValue.toString()); } else { LOG.debug("Not publishing on embedded shell message bus: " + event.getType()); } }); }
From source file:org.ow2.proactive_grid_cloud_portal.rm.client.monitoring.charts.MBeanSourceDetailedView.java
License:Open Source License
public void reload() { DetailViewerField[] fields = new DetailViewerField[attrs.size()]; for (int i = 0; i < fields.length; i++) { fields[i] = new DetailViewerField(attrs.get(i)); }/*from ww w. j a v a2 s . co m*/ setFields(fields); final RMServiceAsync rm = controller.getRMService(); final RMModel model = controller.getModel(); final long t = System.currentTimeMillis(); final LoginModel loginModel = LoginModel.getInstance(); // loading runtime info rm.getNodeMBeanInfo(loginModel.getSessionId(), jmxServerUrl, mbean, attrs, new AsyncCallback<String>() { public void onSuccess(String result) { if (extraCallback != null) { extraCallback.onSuccess(result); } if (!loginModel.isLoggedIn()) return; LogModel.getInstance() .logMessage("Fetched JVM Runtime info in " + (System.currentTimeMillis() - t) + "ms"); JSONArray array = controller.parseJSON(result).isArray(); if (array != null) { DetailViewerRecord dv = new DetailViewerRecord(); for (int i = 0; i < array.size(); i++) { try { JSONObject property = array.get(i).isObject(); String name = property.get("name").isString().stringValue(); JSONValue value = property.get("value"); String valueStr = ""; if (value.isString() != null) { valueStr = value.isString().stringValue(); } else if (value.isNumber() != null) { valueStr = value.isNumber().toString(); } else if (value.isArray() != null) { JSONArray values = value.isArray(); for (int j = 0; j < values.size(); j++) valueStr += values.get(j).isString().stringValue() + " "; } else if (value.isObject() != null) { valueStr = value.toString(); } else { valueStr = value.toString(); } dv.setAttribute(name, valueStr); } catch (Exception e) { // ignore it } } setData(new DetailViewerRecord[] { dv }); } } public void onFailure(Throwable caught) { if (extraCallback != null) { String errmessage = caught.getMessage(); if (caught instanceof RestServerException && errmessage.contains(MonitoringSourceView.NO_MONITORING_INFO_EXCEPTION_STRING)) { extraCallback .onFailure(new Exception("Node Source monitoring information " + "not available.")); } else if (caught instanceof RestServerException && errmessage.contains(MonitoringSourceView.ACCESS_DENIED_EXCEPTION_STRING)) { extraCallback.onFailure(new Exception( "The current user is not authorized to get Node Source monitoring information. ")); } else { extraCallback.onFailure(caught); } } if (JSONUtils.getJsonErrorCode(caught) == 401) { LogModel.getInstance().logMessage("You have been disconnected from the server."); } } }); }
From source file:org.ow2.proactive_grid_cloud_portal.scheduler.client.json.SchedulerJSONUtils.java
License:Open Source License
protected static JSONObject getObject(JSONValue value) throws JSONException { JSONObject jsonObject = value.isObject(); if (jsonObject == null) { throw new JSONException("Expected JSON Object: " + value.toString()); }//from w ww . j av a 2s . com return jsonObject; }
From source file:org.ow2.proactive_grid_cloud_portal.scheduler.client.json.SchedulerJSONUtils.java
License:Open Source License
protected static JSONArray getArray(JSONValue value) throws JSONException { JSONArray arr = value.isArray();/*from w w w. ja v a 2 s . co m*/ if (arr == null) { throw new JSONException("Expected JSON Array: " + value.toString()); } return arr; }
From source file:org.ow2.proactive_grid_cloud_portal.scheduler.client.json.SchedulerJSONUtils.java
License:Open Source License
protected static long getSize(JSONObject obj) throws JSONException { JSONValue jsonTotalValue = obj.get("size"); if (jsonTotalValue == null) { throw new JSONException("Expected JSON Object with attribute total: " + obj.toString()); }/* ww w.j a v a 2 s . c o m*/ JSONNumber jsonTotal = jsonTotalValue.isNumber(); if (jsonTotal == null) { throw new JSONException("Expected JSON number: " + jsonTotalValue.toString()); } return (long) jsonTotal.doubleValue(); }