use of com.google.gwt.json.client.JSONArray 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);
}
use of com.google.gwt.json.client.JSONArray 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);
}
use of com.google.gwt.json.client.JSONArray 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.JSONArray in project che by eclipse.
the class JsonHelper method toMapOfLists.
public static Map<String, List<String>> toMapOfLists(String jsonStr) {
Map<String, List<String>> map = new HashMap<>();
JSONValue parsed = JSONParser.parseStrict(jsonStr);
JSONObject jsonObj = parsed.isObject();
if (jsonObj != null) {
for (String key : jsonObj.keySet()) {
JSONValue jsonValue = jsonObj.get(key);
JSONArray jsonArray = jsonValue.isArray();
List<String> values = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
values.add(jsonArray.get(i).isString().stringValue());
}
map.put(key, values);
}
}
return map;
}
use of com.google.gwt.json.client.JSONArray in project gwtphonegap by dankurka.
the class ContactBrowserImpl method fromJSON.
public static Contact fromJSON(ContactsBrowserImpl controller, JSONObject jsonContact) {
ContactBrowserImpl contact = new ContactBrowserImpl(controller);
// simple fields
contact.setId(getFieldAsString(jsonContact.get(FIELD_ID)));
contact.setDisplayName(getFieldAsString(jsonContact.get(CONTACT_DISPLAY_NAME)));
contact.setNickName(getFieldAsString(jsonContact.get(CONTACT_NICK_NAME)));
contact.setNote(getFieldAsString(jsonContact.get(CONTACT_NOTE)));
// birthday
JSONValue dateValue = jsonContact.get(CONTACT_BIRTHDAY);
if (dateValue != null && dateValue.isNumber() != null) {
contact.setBirthDay(new Date((long) dateValue.isNumber().doubleValue()));
}
// contact fields
JSONArray phoneNumberArray = jsonContact.get(CONTACT_PHONE_NUMBERS).isArray();
LightArray<ContactField> phoneNumbers = getContactFieldsForArray(phoneNumberArray);
contact.setPhoneNumbers(phoneNumbers);
JSONArray emailsArray = jsonContact.get(CONTACT_EMAILS).isArray();
LightArray<ContactField> emails = getContactFieldsForArray(emailsArray);
contact.setEmails(emails);
JSONArray imsArray = jsonContact.get(CONTACT_IMS).isArray();
LightArray<ContactField> ims = getContactFieldsForArray(imsArray);
contact.setIms(ims);
JSONArray photosArray = jsonContact.get(CONTACT_PHOTOS).isArray();
LightArray<ContactField> photos = getContactFieldsForArray(photosArray);
contact.setPhotos(photos);
JSONArray categoriesArray = jsonContact.get(CONTACT_CATEGORIES).isArray();
LightArray<ContactField> categories = getContactFieldsForArray(categoriesArray);
contact.setCategories(categories);
JSONArray urlsArray = jsonContact.get(CONTACT_URLS).isArray();
LightArray<ContactField> urls = getContactFieldsForArray(urlsArray);
contact.setUrls(urls);
ContactName name = getName(jsonContact.get(CONTACT_NAME).isObject());
contact.setName(name);
LightArray<ContactAddress> addresses = getAddressArray(jsonContact.get(CONTACT_ADDRESSES).isArray());
contact.setContactAddresses(addresses);
LightArray<ContactOrganisation> organisations = getContactOrganisationArray(jsonContact.get(CONTACT_ORGANISATION).isArray());
contact.setOrganisations(organisations);
return contact;
}
Aggregations