use of org.json.JSONArray in project solo by b3log.
the class LinkRepositoryImpl method getByAddress.
@Override
public JSONObject getByAddress(final String address) throws RepositoryException {
final Query query = new Query().setFilter(new PropertyFilter(Link.LINK_ADDRESS, FilterOperator.EQUAL, address)).setPageCount(1);
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
return null;
}
return array.optJSONObject(0);
}
use of org.json.JSONArray in project h2o-2 by h2oai.
the class h2oService method ImportCSVFile.
public String ImportCSVFile(String path) {
//example - url http://localhost:54321/2/ImportFiles2.json?path=%2Ftmp%2Fetsy_images%2Fimage_deep_features_csv#
String key;
String h2oUrlImportEndPoint = H2O_HOST_URL + H2O_IMPORT_URL + path;
log.debug("@@@ Calling endpoint {}", h2oUrlImportEndPoint);
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(h2oUrlImportEndPoint, String.class);
//{"Request2":0,"response_info":{"h2o":"paragsanghavi","node":"/172.16.2.45:54321","time":1,
// "status":"done","redirect_url":null},"prefix":"nfs://tmp/etsy_images/deep_features_csv",
// "files":["/tmp/etsy_images/deep_features_csv"],"keys":["nfs://tmp/etsy_images/deep_features_csv"],
// "fails":[],"dels":["nfs://tmp/etsy_images/deep_features_csv"]}
log.debug("@@@ Response json from h2o {}", result);
JSONObject jsonobject = new JSONObject(result);
JSONObject response_info = (JSONObject) jsonobject.get("response_info");
String status = (String) response_info.get("status");
log.debug("!!!!!! Import Status {}", status);
if (status.equalsIgnoreCase("DONE")) {
JSONArray jsonarray = (JSONArray) jsonobject.get("keys");
key = (String) jsonarray.get(0);
System.out.println("!!!!!! Import key : " + key);
log.debug("!!!!!! Import key {}", key);
return key;
} else {
return "error";
}
}
use of org.json.JSONArray in project facebook-android-sdk by facebook.
the class TestUserManagerTests method countTestUsers.
private int countTestUsers() {
TestUserManager testUserManager = createTestUserManager();
String appAccessToken = testUserManager.getAppAccessToken();
assertNotNull(appAccessToken);
Bundle parameters = new Bundle();
parameters.putString("access_token", appAccessToken);
parameters.putString("fields", "id");
GraphRequest requestTestUsers = new GraphRequest(null, "app/accounts/test-users", parameters, null);
GraphResponse response = requestTestUsers.executeAndWait();
JSONArray data = response.getJSONObject().optJSONArray("data");
return data.length();
}
use of org.json.JSONArray in project facebook-android-sdk by facebook.
the class RequestTests method validateMyFriendsResponse.
static void validateMyFriendsResponse(GraphResponse response) {
assertNotNull(response);
assertNull(response.getError());
JSONObject graphResult = response.getJSONObject();
assertNotNull(graphResult);
JSONArray results = graphResult.optJSONArray("data");
assertNotNull(results);
assertNotNull(response.getRawResponse());
}
use of org.json.JSONArray in project facebook-android-sdk by facebook.
the class RequestTests method testExecutePlaceRequestWithSearchText.
@LargeTest
public void testExecutePlaceRequestWithSearchText() {
// Pass a distance without a location to ensure it is correctly ignored.
GraphRequest request = GraphRequest.newPlacesSearchRequest(AccessToken.getCurrentAccessToken(), null, 1000, 5, "Starbucks", null);
GraphResponse response = request.executeAndWait();
assertNotNull(response);
assertNull(response.getError());
JSONObject graphResult = response.getJSONObject();
assertNotNull(graphResult);
JSONArray results = graphResult.optJSONArray("data");
assertNotNull(results);
assertNotNull(response.getRawResponse());
}
Aggregations