本文整理了Java中com.mashape.unirest.http.JsonNode.toString()
方法的一些代码示例,展示了JsonNode.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.toString()
方法的具体详情如下:
包路径:com.mashape.unirest.http.JsonNode
类名称:JsonNode
方法名:toString
暂无
代码示例来源:origin: Kong/unirest-java
public RequestBodyEntity body(JsonNode body) {
this.body = body.toString();
return this;
}
代码示例来源:origin: Kong/unirest-java
public RequestBodyEntity body(JsonNode body) {
return body(body.toString());
}
代码示例来源:origin: RaiMan/SikuliX2
public static JSONObject get(String urlCommand) {
log.trace("get: %s", urlCommand);
HttpResponse<JsonNode> jsonResponse = null;
JSONObject response = null;
try {
jsonResponse = Unirest.get(urlBase + urlCommand)
.header("accept", "application/json")
.asJson();
} catch (UnirestException e) {
log.error("get: %s", e.getMessage());
}
String responseBody = "null";
if (SX.isNotNull(jsonResponse)) {
responseBody = jsonResponse.getBody().toString();
response = SXJson.makeObject(responseBody);
}
log.trace("get: response: %s",jsonResponse.getBody().toString());
return response;
}
代码示例来源:origin: com.mashape.unirest/unirest-java
public RequestBodyEntity body(JsonNode body) {
this.body = body.toString();
return this;
}
代码示例来源:origin: com.github.bingoohuang/unirest-java
public RequestBodyEntity body(JsonNode body) {
this.body = body.toString();
return this;
}
代码示例来源:origin: RaiMan/SikuliX2
public static JSONObject post(String urlCommand, String body) {
log.trace("post: %s body: %s", urlCommand, body);
HttpResponse<JsonNode> jsonResponse = null;
JSONObject response = null;
try {
jsonResponse = Unirest.post(urlBase + urlCommand)
.header("accept", "application/json")
.header("content-type", "application/json")
.body(body)
.asJson();
} catch (UnirestException e) {
log.error("post(): %s", e.getMessage());
}
String responseBody = "null";
if (SX.isNotNull(jsonResponse)) {
responseBody = jsonResponse.getBody().toString();
response = SXJson.makeObject(responseBody);
}
log.trace("post: response: %s", responseBody);
return response;
}
代码示例来源:origin: com.mashape.unirest/unirest-java
public RequestBodyEntity body(JsonNode body) {
return body(body.toString());
}
代码示例来源:origin: com.github.bingoohuang/unirest-java
public RequestBodyEntity body(JsonNode body) {
return body(body.toString());
}
代码示例来源:origin: biezhi/java-library-examples
@Override
public void completed(HttpResponse<JsonNode> response) {
int code = response.getStatus();
JsonNode body = response.getBody();
System.out.println("Status Code: " + code);
System.out.println(body.toString());
}
代码示例来源:origin: biezhi/java-library-examples
public static void main(String[] args) throws UnirestException {
HttpResponse<JsonNode> jsonResponse = Unirest.get("http://httpbin.org/basic-auth/biezhi/123456")
.basicAuth("biezhi", "123456").asJson();
System.out.println(jsonResponse.getBody().toString());
}
}
代码示例来源:origin: thejamesthomas/javabank
public String deleteImposter(int port) {
try {
HttpResponse<JsonNode> response = Unirest.delete(baseUrl + "/imposters/" + port).asJson();
return response.getBody().toString();
} catch (UnirestException e) {
return null;
}
}
代码示例来源:origin: biezhi/java-library-examples
public static void main(String[] args) throws UnirestException {
HttpResponse<JsonNode> jsonResponse = Unirest.post("http://httpbin.org/post")
.header("accept", "application/json")
.field("parameter", "value")
.field("file", new File("/tmp/file"))
.asJson();
System.out.println(jsonResponse.getBody().toString());
}
}
代码示例来源:origin: biezhi/java-library-examples
public static void main(String[] args) throws UnirestException {
HttpResponse<JsonNode> jsonResponse = Unirest.post("http://httpbin.org/post")
.header("accept", "application/json")
.body("{\"parameter\":\"value\", \"foo\":\"bar\"}")
.asJson();
System.out.println(jsonResponse.getBody().toString());
}
}
代码示例来源: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: thejamesthomas/javabank
public Imposter getImposter(int port) throws ParseException {
try {
HttpResponse<JsonNode> response = Unirest.get(baseUrl + "/imposters/" + port).asJson();
String responseJson = response.getBody().toString();
return ImposterParser.parse(responseJson);
} catch (UnirestException e) {
return null;
}
}
}
代码示例来源:origin: thejamesthomas/javabank
@Test
public void shouldDeleteAnImposter() throws UnirestException {
String deleteResponse = "{ url: http://localhost:5757 }";
when(Unirest.delete(Client.DEFAULT_BASE_URL + "/imposters/5757")).thenReturn(requestWithBody);
when(requestWithBody.asJson()).thenReturn(httpResponse);
when(httpResponse.getBody()).thenReturn(value);
when(value.toString()).thenReturn(deleteResponse);
String response = client.deleteImposter(5757);
assertThat(response).contains("5757").contains("http");
}
代码示例来源:origin: openpnp/openpnp
public Image uploadImage(File file) throws Exception {
// {"data":{"bandwidth":0,"nsfw":null,"is_ad":false,"link":"http://i.imgur.com/4a2U4HI.png","description":null,"section":null,"title":null,"type":"image/png","tags":[],"deletehash":"g5KtSKSSXT2l54Q","datetime":1490023631,"account_id":0,"size":258,"width":35,"account_url":null,"name":"","animated":false,"id":"4a2U4HI","in_gallery":false,"vote":null,"favorite":false,"views":0,"height":35},"success":true,"status":200}
HttpResponse<JsonNode> response = Unirest
.post("https://api.imgur.com/3/image")
.header("accept", "application/json")
.header("Authorization", "Client-ID " + clientId)
.field("image", file)
.field("name", file.getName())
.field("title", file.getName())
.asJson();
if (!response.getBody().getObject().getBoolean("success")) {
Logger.debug(response.getBody().toString());
throw new Exception(response.getBody().getObject().getJSONObject("data").getString("error"));
}
Image image = new Image();
image.id = response.getBody().getObject().getJSONObject("data").getString("id");
image.deleteHash = response.getBody().getObject().getJSONObject("data").getString("deletehash");
return image;
}
代码示例来源:origin: biezhi/java-library-examples
public static void main(String[] args) throws UnirestException {
HttpResponse<JsonNode> jsonResponse = Unirest.post("http://httpbin.org/post")
.header("accept", "application/json")
.queryString("apiKey", "123")
.field("parameter", "value")
.field("foo", "bar")
.asJson();
System.out.println(jsonResponse.getBody().toString());
}
}
代码示例来源:origin: thejamesthomas/javabank
@Test
public void shouldGetAnImposter() throws ParseException, UnirestException {
int port = 5757;
String jsonString = "test string";
Imposter expectedImposter = new ImposterBuilder().onPort(5757).build();
when(Unirest.get(Client.DEFAULT_BASE_URL + "/imposters/5757")).thenReturn(getRequest);
when(getRequest.asJson()).thenReturn(httpResponse);
when(httpResponse.getBody()).thenReturn(value);
when(value.toString()).thenReturn(jsonString);
when(ImposterParser.parse(jsonString)).thenReturn(expectedImposter);
Imposter actualImposter = client.getImposter(port);
assertThat(actualImposter.getPort()).isEqualTo(expectedImposter.getPort());
}
代码示例来源:origin: net.dv8tion/JDA
@Override
public Message sendFile(File file)
{
JDAImpl api = (JDAImpl) getJDA();
try
{
HttpResponse<JsonNode> response = Unirest.post("https://discordapp.com/api/channels/" + getId() + "/messages")
.header("authorization", getJDA().getAuthToken())
.header("user-agent", JDAInfo.GITHUB + " " + JDAInfo.VERSION)
.field("file", file)
.asJson();
JSONObject messageJson = new JSONObject(response.getBody().toString());
return new EntityBuilder(api).createMessage(messageJson);
}
catch (UnirestException e)
{
e.printStackTrace();
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!