Android Studio,截击我没有得到JSON响应
我已经用jasonweb令牌构建了一个laravelrestapi。现在我想制作一个应用程序,将数据发送到Web服务。在这里,我首先尝试用姓名、电子邮件和密码对自己进行身份验证,但我没有得到令牌作为答案。我也没有得到一个错误,什么也没有发生Android Studio,截击我没有得到JSON响应,android,post,request,android-volley,response,Android,Post,Request,Android Volley,Response,我已经用jasonweb令牌构建了一个laravelrestapi。现在我想制作一个应用程序,将数据发送到Web服务。在这里,我首先尝试用姓名、电子邮件和密码对自己进行身份验证,但我没有得到令牌作为答案。我也没有得到一个错误,什么也没有发生 private void sendAndRequestResponse() { try { JSONObject jsonBody = new JSONObject(); jsonBody.put("name", "
private void sendAndRequestResponse() {
try {
JSONObject jsonBody = new JSONObject();
jsonBody.put("name", "ida");
jsonBody.put("email", "ida@gmail.com");
jsonBody.put("password", "secret");
final String mRequestBody = jsonBody.toString();
//RequestQueue initialized
mRequestQueue = Volley.newRequestQueue(this);
mJsonRequest = new JsonObjectRequest(
Request.Method.POST, url, jsonBody,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d(TAG, response.toString());
answer.setText(response.toString());
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
}
});
mRequestQueue.add(mJsonRequest);
} catch (JSONException e) {
e.printStackTrace();
}
}
您需要启动请求队列才能进行请求调用 之后
mRequestQueue.add(mJsonRequest);
添加以下内容
mRequestQueue.start();
现在我没有得到一个应该得到的值的答案,有没有办法过滤响应我只需要一个特定值,而不是全部你在JSONObject中得到一个答案,所以你需要解析JSON对象,然后你才能得到ans