java – Retrieving waypoint_order for Directions API-ThrowExceptions

Exception or error:

I’m trying to retrieve the waypoint_order array from the JSON object returned from a request sent using Google’s Direction API, using the url:,139.7690174&destination=35.680399699999995,139.7690174&waypoints=optimize:true|34.6937249,135.5022535|35.011564,135.7681489&mode=TRANSIT&key=KEY_VALUE

private void jsonParse(String url) {
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
            new Response.Listener<JSONObject>() {
                public void onResponse(JSONObject response) {
                    textView.setText("Response: " + response.toString());
            }, new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {

My question is, how do I retrieve the waypoint_order in the onResponse method? From what I know, I can only retrieve int values, double values, etc but not int array using the get methods. I can confirm that using response.toString() in the onReponse method gives me the JSON as a String when set to a TextView, but I do not know how to get the waypoint_order array out and display it to a TextView.

I’m still new to programming so any help is appreciated.

Also, some may notice that the request actually gives the order in terms of driving instead of transit. I have read some other questions here and there doesn’t seem to be any solutions to the zero_results problem if I set it to “transit” instead of “TRANSIT” from what I’ve read so if there is a solution to that too it would be great.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *