Search in sources :

Example 41 with JSONString

use of com.google.gwt.json.client.JSONString in project rstudio by rstudio.

the class RemoteServer method executeDebugSource.

public void executeDebugSource(String fileName, ArrayList<Integer> topBreakLines, ArrayList<Integer> debugBreakLines, int step, int mode, ServerRequestCallback<TopLevelLineData> requestCallback) {
    JSONArray params = new JSONArray();
    params.set(0, new JSONString(fileName));
    params.set(1, JSONUtils.toJSONNumberArray(topBreakLines));
    params.set(2, JSONUtils.toJSONNumberArray(debugBreakLines));
    params.set(3, new JSONNumber(step));
    params.set(4, new JSONNumber(mode));
    sendRequest(RPC_SCOPE, EXECUTE_DEBUG_SOURCE, params, requestCallback);
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONNumber(com.google.gwt.json.client.JSONNumber) JSONString(com.google.gwt.json.client.JSONString)

Example 42 with JSONString

use of com.google.gwt.json.client.JSONString in project rstudio by rstudio.

the class RemoteServer method getRmdPublishDetails.

@Override
public void getRmdPublishDetails(String target, ServerRequestCallback<RmdPublishDetails> requestCallback) {
    JSONArray params = new JSONArray();
    params.set(0, new JSONString(target));
    sendRequest(RPC_SCOPE, GET_RMD_PUBLISH_DETAILS, params, requestCallback);
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 43 with JSONString

use of com.google.gwt.json.client.JSONString in project che by eclipse.

the class StringListUnmarshaller method toList.

public List<String> toList(String jsonStr) {
    JSONValue parsed = JSONParser.parseStrict(jsonStr);
    JSONArray jsonArray = parsed.isArray();
    if (jsonArray == null) {
        return Collections.emptyList();
    }
    List<String> list = new ArrayList<>();
    for (int i = 0; i < jsonArray.size(); i++) {
        JSONValue jsonValue = jsonArray.get(i);
        JSONString jsonString = jsonValue.isString();
        String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
        list.add(stringValue);
    }
    return list;
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONArray(com.google.gwt.json.client.JSONArray) ArrayList(java.util.ArrayList) JSONString(com.google.gwt.json.client.JSONString) JSONString(com.google.gwt.json.client.JSONString)

Example 44 with JSONString

use of com.google.gwt.json.client.JSONString in project che by eclipse.

the class JsonHelper method toMap.

public static Map<String, String> toMap(String jsonStr) {
    Map<String, String> map = new HashMap<String, String>();
    JSONValue parsed = JSONParser.parseStrict(jsonStr);
    JSONObject jsonObj = parsed.isObject();
    if (jsonObj != null) {
        for (String key : jsonObj.keySet()) {
            JSONValue jsonValue = jsonObj.get(key);
            JSONString jsonString = jsonValue.isString();
            // if the json value is a string, set the unescaped value, else set the json representation of the value
            String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue();
            map.put(key, stringValue);
        }
    }
    return map;
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject) HashMap(java.util.HashMap) JSONString(com.google.gwt.json.client.JSONString) JSONString(com.google.gwt.json.client.JSONString)

Example 45 with JSONString

use of com.google.gwt.json.client.JSONString in project rstudio by rstudio.

the class RemoteServer method sendRequest.

private <T> void sendRequest(String scope, String method, String param1, String param2, ServerRequestCallback<T> requestCallback) {
    JSONArray params = new JSONArray();
    // pass JSONNull if the string is null
    params.set(0, param1 != null ? new JSONString(param1) : JSONNull.getInstance());
    params.set(1, param2 != null ? new JSONString(param2) : JSONNull.getInstance());
    sendRequest(scope, method, params, requestCallback);
}
Also used : JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Aggregations

JSONString (com.google.gwt.json.client.JSONString)230 JSONArray (com.google.gwt.json.client.JSONArray)179 JSONNumber (com.google.gwt.json.client.JSONNumber)71 JSONObject (com.google.gwt.json.client.JSONObject)69 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)6 HashMap (java.util.HashMap)6 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)6 Point (org.rstudio.studio.client.workbench.views.plots.model.Point)6 JSONValue (com.google.gwt.json.client.JSONValue)5 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)5 PerunError (cz.metacentrum.perun.webgui.model.PerunError)5 ArrayList (java.util.ArrayList)5 JsArrayString (com.google.gwt.core.client.JsArrayString)4 Map (java.util.Map)4 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 JSONBoolean (com.google.gwt.json.client.JSONBoolean)2 GwtTestTest (com.googlecode.gwt.test.GwtTestTest)2 GetFacilityState (cz.metacentrum.perun.webgui.json.propagationStatsReader.GetFacilityState)2