【问题标题】:how to send JSON request and get JSON response from server [duplicate]如何发送 JSON 请求并从服务器获取 JSON 响应 [重复]
【发布时间】:2019-04-23 17:50:41
【问题描述】:

我有一个服务器,我需要向它发送请求并获得响应。 我正在使用volley,这就是我到目前为止所做的

JSONObject request=new JSONObject();
try {
    request.put("ticket_id", ticket_id);
    request.put("start", start);
    request.put("extra", extra);
    request.put("care_category", care_category);
    request.put("k_means", "10");
    request.put("vendor", vendor);
    request.put("earlier_enteries", earlier_enteries);
} catch (JSONException e) {
    e.printStackTrace();
}

响应将类似于:

{"calculation":5.4444"}

我应该如何提出我的请求,或者是否有更好的方法?

【问题讨论】:

  • 我需要将 JSON 发送到服务器并取回 JSON。

标签: java android client android-volley


【解决方案1】:

您必须使用 HTTPs 请求(GET 和 POST)。改造和 Gson 将完成它。

有很多关于它的教程和示例。 见Retrofit Android Example HTTP GET Request

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-03
    • 2020-11-19
    • 2019-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-03
    相关资源
    最近更新 更多