com.mashape.unirest.request.HttpRequest.asJson()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中com.mashape.unirest.request.HttpRequest.asJson()方法的一些代码示例,展示了HttpRequest.asJson()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.asJson()方法的具体详情如下:
包路径:com.mashape.unirest.request.HttpRequest
类名称:HttpRequest
方法名:asJson

HttpRequest.asJson介绍

暂无

代码示例

代码示例来源:origin: DiUS/pact-workshop-jvm

private Optional<JsonNode> loadProviderJson(String dateTime) throws UnirestException {
 HttpRequest getRequest = Unirest.get(url + "/provider.json");
 if (StringUtils.isNoneEmpty(dateTime)) {
  getRequest = getRequest.queryString("validDate", dateTime);
 }
 HttpResponse<JsonNode> jsonNodeHttpResponse = getRequest.asJson();
 if (jsonNodeHttpResponse.getStatus() == 200) {
  return Optional.of(jsonNodeHttpResponse.getBody());
 } else {
  return Optional.empty();
 }
}

代码示例来源:origin: biezhi/java-library-examples

public static void main(String[] args) throws UnirestException {
    HttpResponse<JsonNode> response = Unirest.get("http://httpbin.org/{method}")
        .routeParam("method", "get")
        .queryString("name", "biezhi")
        .asJson();

    System.out.println(response.getBody().toString());
  }
}

代码示例来源:origin: com.infotel.seleniumRobot/core

public void runTest(RemoteWebDriver driver) {
  
  // logging node ip address:
  try {
    JSONObject object = Unirest.get(String.format("http://%s:%d/grid/api/testsession/", hubUrl.getHost(), hubUrl.getPort()))
      .queryString("session", driver.getSessionId().toString())
      .asJson()
      .getBody()
      .getObject();
    
    nodeUrl = (String) object.get("proxyId");
    String node = nodeUrl.split("//")[1].split(":")[0];
    String browserName = driver.getCapabilities().getBrowserName();
    String version = driver.getCapabilities().getVersion();
    sessionId = driver.getSessionId();
    logger.info("WebDriver is running on node " + node + ", " + browserName + " " + version + ", session " + sessionId);
    
  } catch (Exception ex) {
    logger.error(ex);
  } 
}

代码示例来源:origin: com.infotel.seleniumRobot/grid-extensions

public void runTest(RemoteWebDriver driver) {
  
  // logging node ip address:
  try {
    JSONObject object = Unirest.get(String.format("http://%s:%d/grid/api/testsession/", hubUrl.getHost(), hubUrl.getPort()))
      .queryString("session", driver.getSessionId().toString())
      .asJson()
      .getBody()
      .getObject();
    
    nodeUrl = (String) object.get("proxyId");
    String node = nodeUrl.split("//")[1].split(":")[0];
    String browserName = driver.getCapabilities().getBrowserName();
    String version = driver.getCapabilities().getVersion();
    sessionId = driver.getSessionId();
    logger.info("WebDriver is running on node " + node + ", " + browserName + " " + version + ", session " + sessionId);
    
  } catch (Exception ex) {
    logger.error(ex);
  } 
}

代码示例来源:origin: io.github.kjens93.edmunds/edmunds

HttpResponse<JsonNode> response = Unirest.get(url)
    .queryString(parameters)
    .asJson();
if (response.getStatus() == 200)
  return response.getBody().toString();

代码示例来源:origin: simplesteph/medium-blog-kafka-udemy

public ReviewApiResponse reviewApi(Integer pageSize, Integer page) throws HttpException {
  String url = "https://www.udemy.com/api-2.0/courses/" + courseId + "/reviews";
  HttpResponse<JsonNode> jsonResponse = null;
  try {
    jsonResponse = Unirest.get(url)
        .queryString("page", page)
        .queryString("page_size", pageSize)
        .queryString("fields[course_review]", "title,content,rating,created,modified,user_modified,user,course")
        .asJson();
  } catch (UnirestException e) {
    throw new HttpException(e.getMessage());
  }
  if (jsonResponse.getStatus() == 200) {
    JSONObject body = jsonResponse.getBody().getObject();
    Integer count = body.getInt("count");
    String next = body.optString("next");
    String previous = body.optString("previous");
    List<Review> reviews = this.convertResults(body.getJSONArray("results"));
    ReviewApiResponse reviewApiResponse = new ReviewApiResponse(count, next, previous, reviews);
    return reviewApiResponse;
  }
  throw new HttpException("Udemy API Unavailable");
}

代码示例来源:origin: Apicurio/apicurio-studio

HttpRequest request = Unirest.get(branchesUrl);
addSecurityTo(request);
HttpResponse<com.mashape.unirest.http.JsonNode> response = request.asJson();

代码示例来源:origin: Apicurio/apicurio-studio

HttpRequest request = Unirest.get(reposUrl);
addSecurityTo(request);
HttpResponse<com.mashape.unirest.http.JsonNode> response = request.asJson();

代码示例来源:origin: Apicurio/apicurio-studio

HttpRequest request = Unirest.get(teamsUrl);
addSecurityTo(request);
HttpResponse<com.mashape.unirest.http.JsonNode> response = request.asJson();
  HttpRequest request = Unirest.get(teamsUrl);
  addSecurityTo(request);
  HttpResponse<com.mashape.unirest.http.JsonNode> response = request.asJson();

代码示例来源:origin: Kong/Astronode-Broadcaster

switch (method) {
case GET:
  response = Unirest.get(url).queryString(parameters).asJson();
  break;
case POST:

相关文章