本文整理了Java中com.mashape.unirest.http.JsonNode.getArray()
方法的一些代码示例,展示了JsonNode.getArray()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.getArray()
方法的具体详情如下:
包路径:com.mashape.unirest.http.JsonNode
类名称:JsonNode
方法名:getArray
暂无
代码示例来源:origin: mesos/elasticsearch
public Integer getDocumentCount(String httpAddress) throws UnirestException {
JSONArray responseElements = Unirest.get("http://" + httpAddress + "/_count").asJson().getBody().getArray();
LOGGER.debug(responseElements);
return responseElements.getJSONObject(0).getInt("count");
}
代码示例来源:origin: mesos/elasticsearch
public List<JSONObject> getTasks() {
List<JSONObject> tasks = new ArrayList<>();
LOGGER.debug("Fetching tasks on " + tasksEndPoint);
final AtomicReference<HttpResponse<JsonNode>> response = new AtomicReference<>();
Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(() -> { // This can take some time, somtimes.
try {
response.set(Unirest.get(tasksEndPoint).asJson());
return true;
} catch (UnirestException e) {
LOGGER.debug(e);
return false;
}
});
for (int i = 0; i < response.get().getBody().getArray().length(); i++) {
JSONObject jsonObject = response.get().getBody().getArray().getJSONObject(i);
tasks.add(jsonObject);
}
return tasks;
}
代码示例来源:origin: bosondata/elasticsearch-analysis-bosonnlp
try {
JSONArray jaTemp = jn.getArray();
if (jaTemp.length() > 0) {
JSONObject jo = jaTemp.getJSONObject(0);
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private List<Commit> getCommits(Integer projectId) throws UnirestException {
GetRequest commitsRequest = Unirest.get(apiEndPoint + "/projects/"+projectId.toString()+"/repository/commits").header("PRIVATE-TOKEN", privateToken);
if (getRequestOK(commitsRequest)) {
String json = commitsRequest.asJson().getBody().getArray().toString();
return Arrays.asList(mapper.readValue(json, Commit[].class));
}
return null;
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private List<MergeRequest> getMergeRequests(Integer projectId) throws UnirestException {
GetRequest mergeRequestsRequest = Unirest.get(apiEndPoint + "/projects/"+projectId.toString()+"/merge_requests?state=merged").header("PRIVATE-TOKEN", privateToken);
if (getRequestOK(mergeRequestsRequest)) {
String json = mergeRequestsRequest.asJson().getBody().getArray().toString();
return Arrays.asList(mapper.readValue(json, MergeRequest[].class));
}
return null;
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private List<Issue> getIssues(Integer projectId) throws UnirestException {
GetRequest mergeRequestsRequest = Unirest.get(apiEndPoint + "/projects/"+projectId.toString()+"/issues?state=closed").header("PRIVATE-TOKEN", privateToken);
if (getRequestOK(mergeRequestsRequest)) {
String json = mergeRequestsRequest.asJson().getBody().getArray().toString();
return Arrays.asList(mapper.readValue(json, Issue[].class));
}
return null;
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private List<Tag> getTags(Integer projectId) throws UnirestException {
GetRequest tagsRequest = Unirest.get(apiEndPoint + "/projects/"+projectId.toString()+"/repository/tags").header("PRIVATE-TOKEN", privateToken);
if (getRequestOK(tagsRequest)) {
String json = tagsRequest.asJson().getBody().getArray().toString();
List<Tag> result = Arrays.asList(mapper.readValue(json, Tag[].class));
Comparator<? super Tag> c = new Comparator<Tag>() {
@Override
public int compare(Tag t1, Tag t2) {
return t1.getCommit().getCommittedDate().compareTo(t2.getCommit().getCommittedDate());
}
};
Collections.sort(result, c); // sort in chronological time
return result;
}
return null;
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private List<Project> getProjects() throws UnirestException {
if (projects != null) {
return projects;
}
GetRequest projectsRequest = Unirest.get(apiEndPoint + "/projects").header("PRIVATE-TOKEN", privateToken);
if (getRequestOK(projectsRequest)) {
String json = projectsRequest.asJson().getBody().getArray().toString();
projects = Arrays.asList(mapper.readValue(json, Project[].class));
}
return projects;
}
代码示例来源:origin: simplesteph/kafka-connect-github-source
switch (jsonResponse.getStatus()){
case 200:
return jsonResponse.getBody().getArray();
case 401:
throw new ConnectException("Bad GitHub credentials provided, please edit your config");
代码示例来源:origin: Apicurio/apicurio-studio
throw new Exception("Failed to list Issues: " + response.getStatusText());
JSONArray issueNodes = response.getBody().getArray();
issueNodes.forEach(issueNode -> {
JSONObject issue = (JSONObject) issueNode;
代码示例来源:origin: Kong/Astronode-Broadcaster
JSONArray servers = response.getBody().getArray();
Set<InetSocketAddress> serverObjects = new HashSet<>();
for (int i = 0; i < servers.length(); i++) {
内容来源于网络,如有侵权,请联系作者删除!