title: How to return a JSONObject using Volley
body: <p>I wrote this method:</p>
  
  <pre><code>public JSONObject getJSONFromUrl(String url, final Map&lt;String, String&gt; params) {
      StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener&lt;String&gt;() {
          /**
           *
           * @param response
           */
          @Override
          public void onResponse(String response) {
              try {
                  JSONObject jsonResponse = new JSONObject(response);
  
                  Log.v("JSONParser", "response: " + jsonResponse.toString());
              } catch(JSONException e) {
                  e.printStackTrace();
              }
          }
      }, new Response.ErrorListener() {
          /**
           *
           * @param error
           */
          @Override
          public void onErrorResponse(VolleyError error) {
              error.printStackTrace();
          }
      }) {
          /**
           *
           * @return
           * @throws AuthFailureError
           */
          @Override
          protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
              return params;
          }
      };
  
      Volley.newRequestQueue(this.context).add(post);
  
      return null;
  }
  </code></pre>
  
  <p>I need to return that <code>JSONObject</code> that i create in <code>onResponse</code> but i cant figure out how to do it. Is there any way to return the JSONObject? I also cant assign the JSONObject to a final variable inside the method and return it.</p>