Search in sources :

Example 1 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 2 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 3 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)

Example 4 with JSONString

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

the class ApplicationFormPage method tryToFindUserByName.

/**
	 * Try to find user by name
	 *
	 * If user found, message box shown
	 *
	 * @param jso returned data
	 */
private void tryToFindUserByName(JavaScriptObject jso) {
    // try to find
    JsonPostClient jspc = new JsonPostClient(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            ArrayList<Identity> users = JsonUtils.<Identity>jsoAsList(jso);
            if (users != null && !users.isEmpty())
                similarUsersFound(users);
        }
    });
    JSONObject query = new JSONObject();
    if (jso == null) {
        // before app submission
        jspc.sendData("registrarManager/checkForSimilarUsers", query);
    } else {
        // after app submission
        query.put("voId", new JSONNumber(vo.getId()));
        if (group != null) {
            query.put("groupId", new JSONNumber(group.getId()));
        } else {
            query.put("groupId", new JSONNumber(0));
        }
        query.put("type", new JSONString(type));
        jspc.sendData("registrarManager/checkForSimilarUsers", query);
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) ArrayList(java.util.ArrayList) JSONNumber(com.google.gwt.json.client.JSONNumber) JSONString(com.google.gwt.json.client.JSONString)

Example 5 with JSONString

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

the class RemoteServer method openDocument.

public void openDocument(String path, String filetype, String encoding, ServerRequestCallback<SourceDocument> requestCallback) {
    JSONArray params = new JSONArray();
    params.set(0, new JSONString(path));
    params.set(1, new JSONString(filetype));
    params.set(2, encoding != null ? new JSONString(encoding) : JSONNull.getInstance());
    sendRequest(RPC_SCOPE, OPEN_DOCUMENT, 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)277 JSONArray (com.google.gwt.json.client.JSONArray)189 JSONObject (com.google.gwt.json.client.JSONObject)110 JSONNumber (com.google.gwt.json.client.JSONNumber)85 JSONValue (com.google.gwt.json.client.JSONValue)13 HashMap (java.util.HashMap)12 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 Map (java.util.Map)10 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)9 PerunError (cz.metacentrum.perun.webgui.model.PerunError)9 Material (org.cesiumjs.cs.scene.Material)9 MaterialOptions (org.cesiumjs.cs.scene.options.MaterialOptions)9 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)8 MetaData (com.ait.tooling.nativetools.client.collection.MetaData)7 ArrayList (java.util.ArrayList)7 JsArrayString (com.google.gwt.core.client.JsArrayString)6 RequestBuilder (com.google.gwt.http.client.RequestBuilder)6 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)6 Point (org.rstudio.studio.client.workbench.views.plots.model.Point)6 Request (com.google.gwt.http.client.Request)5