Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Emacs Request | 562 | 2 months ago | 6 | gpl-3.0 | Emacs Lisp | |||||
Request.el -- Easy HTTP request for Emacs Lisp | ||||||||||
Nodb | 330 | 1 | 3 years ago | 7 | September 26, 2017 | 14 | Python | |||
NoDB isn't a database.. but it sort of looks like one. | ||||||||||
Pyawssfn | 206 | 4 years ago | 1 | other | Python | |||||
Tools for converting Python code to AWS Step Function json | ||||||||||
Burner.kiwi | 195 | a month ago | May 27, 2021 | 9 | mit | Go | ||||
No bullshit temporary mail service written in Go | ||||||||||
Json Serverless | 183 | 2 | 25 days ago | 71 | February 27, 2021 | 43 | mit | TypeScript | ||
Transform a JSON file into a serverless REST API in AWS cloud | ||||||||||
Bender | 177 | a year ago | 14 | apache-2.0 | Java | |||||
Bender - Serverless ETL Framework | ||||||||||
Node Lambda Log | 146 | 18 | 29 | a year ago | 24 | December 10, 2021 | 8 | mit | JavaScript | |
Basic logging mechanism for Node 10+ Lambda Functions | ||||||||||
Athena Express | 143 | 3 | a year ago | 52 | March 22, 2022 | 20 | mit | JavaScript | ||
Athena-Express can simplify executing SQL queries in Amazon Athena AND fetching cleaned-up JSON results in the same synchronous or asynchronous request - well suited for web applications. | ||||||||||
Aws Lambda Scala | 132 | 2 years ago | 14 | February 01, 2021 | 2 | mit | Scala | |||
Writing AWS Lambdas in Scala | ||||||||||
Jgsk | 113 | 4 years ago | Scala | |||||||
Java,Groovy,Scala,Kotlin 四种语言的特点对比 |
Edit root/app/build.gradle
like below.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.setreuid:httpjson:1.0.12'
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.setreuid</groupId>
<artifactId>httpjson</artifactId>
<version>1.0.12</version>
</dependency>
import java.util.HashMap;
import cc.udp.httpjson.HttpJson;
import cc.udp.httpjson.HttpJsonObject;
import cc.udp.httpjson.HttpJsonTask;
import cc.udp.httpjson.HttpBytesTask;
파라미터 없이 JSON 파싱
String url = "https://jsonplaceholder.typicode.com/posts/1";
new HttpJson(url, null, new HttpJsonTask() {
@Override
public void done(HttpJsonObject json)
{
if (json == null)
{
return;
}
// {
// "userId": 1,
// "id": 1,
// "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
// "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
// }
// Check json string
System.out.println("JSON: " + json.toString());
String id = json.getInt("id");
String title = json.getString("title");
System.out.println("id: " + id);
System.out.println("title: " + title);
}
}).get();
new HttpJson("https://jsonplaceholder.typicode.com/posts/1")
.then((HttpJsonObject json) -> {
// Check json string
System.out.println("JSON: " + json.toString());
String id = json.getInt("id");
String title = json.getString("title");
System.out.println("id: " + id);
System.out.println("title: " + title);
})
.except((e) -> {
System.out.println(e.getMessage());
})
.get();
메서드 체인을 이용한 JSON 값 가져오기
String url = "https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA";
new HttpJson(url, null, new HttpJsonTask() {
@Override
public void done(HttpJsonObject json)
{
if (json == null)
{
return;
}
// {
// "results" : [
// {
// "address_components" : [
// {
// "long_name" : "Google Building 41",
// "short_name" : "Google Bldg 41",
// "types" : [ "premise" ]
// },
// ...
// ],
// "status" : "OK"
// }
// Check json string
System.out.println("JSON: " + json.toString());
String status = json.getString("status");
String addressLongName = json.getArray("results").get(0)
.getArray("address_components").get(0)
.getString("long_name");
System.out.println("status: " + status);
System.out.println("addressLongName: " + addressLongName);
}
}).get();
파라미터 포함하여 POST JSON 파싱
String url = "http://p.udp.cc/jsonPostTest.php";
HashMap<String, String> params = new HashMap<String, String>();
params.put("test-key", "A123456789B");
new HttpJson(url, params, new HttpJsonTask() {
@Override
public void done(HttpJsonObject json)
{
if (json == null)
{
return;
}
// {
// "test-key": "A123456789B"
// }
// Check json string
System.out.println("JSON: " + json.toString());
String value = json.getString("test-key");
System.out.println("test-key: " + value);
}
}).post();
new HttpJson("http://p.udp.cc/jsonPostTest.php")
.addField("test-key", "A123456789B")
.then((HttpJsonObject json) -> {
// Check json string
System.out.println("JSON: " + json.toString());
String value = json.getString("test-key");
System.out.println("test-key: " + value);
})
.except((e) -> {
System.out.println(e.getMessage());
})
.post();
파라미터 포함하여 GET JSON 파싱
String url = "http://p.udp.cc/jsonGetTest.php";
// http://p.udp.cc/jsonGetTest.php?test-key=A123456789B
HashMap<String, String> params = new HashMap<String, String>();
params.put("test-key", "A123456789B");
new HttpJson(url, params, new HttpJsonTask() {
@Override
public void done(HttpJsonObject json)
{
if (json == null)
{
return;
}
// {
// "test-key": "A123456789B"
// }
// Check json string
System.out.println("JSON: " + json.toString());
String value = json.getString("test-key");
System.out.println("test-key: " + value);
}
}).get();
new HttpJson("http://p.udp.cc/jsonGetTest.php")
.addField("test-key", "A123456789B")
.then((HttpJsonObject json) -> {
// Check json string
System.out.println("JSON: " + json.toString());
String value = json.getString("test-key");
System.out.println("test-key: " + value);
})
.except((e) -> {
System.out.println(e.getMessage());
})
.get();
파라미터 포함하지 않고 단순 호출
String url = "http://p.udp.cc/jsonPostTest.php";
new HttpJson(url, null, null).post();
파라미터 포함하여 단순 호출
String url = "http://p.udp.cc/jsonPostTest.php";
HashMap<String, String> params = new HashMap<String, String>();
params.put("test-key", "A123456789B");
new HttpJson(url, params, null).post();
헤더 추가하기
Content-Type
is specified asapplication/json
, parameters are sent in JSON format.application/x-www-form-urlencoded
is the default value ofContent-Type
.Content-Type
을 application/json
으로 지정하면 JSON 형태로 파라미터를 전송합니다.application/x-www-form-urlencoded
이 Content-Type
의 기본값입니다.new HttpJson("http://p.udp.cc/jsonPostTest.php")
.addHeader("Content-Type", "application/json")
.addField("test-key", "A123456789B")
.then((HttpJsonObject json) -> {
// Check json string
System.out.println("JSON: " + json.toString());
String value = json.getString("test-key");
System.out.println("test-key: " + value);
})
.except((e) -> {
System.out.println(e.getMessage());
})
.post();
바이너리 값 가져오기
public static String byteArrayToHexString(byte[] bytes){
StringBuilder sb = new StringBuilder();
for(byte b : bytes){
sb.append(String.format("%02X", b&0xff));
}
return sb.toString();
}
new HttpJson("https://s.yimg.com/rz/p/yahoo_frontpage_en-US_s_f_p_205x58_frontpage_2x.png")
.then((byte[] binary) -> {
System.out.println("binary: " + byteArrayToHexString(binary));
// binary: 89504E470D0A1A0A0000000D494844520000019A0000007408030...
})
.except((e) -> {
System.out.println(e.getMessage());
})
.get();
Return type | Method name | Parameters |
---|---|---|
HttpJsonObject | getObject | String key |
ArrayList<HttpJsonObject> | getArray | String key |
String | getString | String key |
int | getInt | String key |
float | getFloat | String key |
double | getDouble | String key |
byte[] | getBytes | String key |
Object | get | String key |