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;
}
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;
}
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);
}
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);
}
}
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);
}
Aggregations