0

i had a Uniform Resource Locator (URL) that contain JSON Array of [1579.39734, 2523,679.59824966966,4327116] with key name. How can i get the data element of the JSON Array using volley? Can anyone help?

Below is my coding but is not working.

private void loadJsonArray() {
        JsonArrayRequest jsArrayRequest = new JsonArrayRequest
                (Request.Method.POST, new_url, null, new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        double[] value=new double[3];
                        pDialog.dismiss();
                        for (int count =0; count < response.length(); count++) {
                            try {

                                  value[count]=response.getDouble(count);
                            }


                            catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                        text1.setText(String.valueOf(value[0]));
                        text2.setText(String.valueOf(value[1]));
                        text3.setText(String.valueOf(value[2]));
                        text4.setText(String.valueOf(value[3]));
                    }






                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(getApplicationContext(), "Error....", Toast.LENGTH_SHORT).show();
                        error.printStackTrace();

                    }
                });
        Singleton.getistance(this).addToRequestque(jsArrayRequest);


    }
4
  • sorry is without the key name Commented May 5, 2018 at 6:55
  • 1
    what code do you have at the moment? need a starting point Commented May 5, 2018 at 6:56
  • 1
    Possible duplicate of Parse JSON Array without Key in Android Commented May 5, 2018 at 7:00
  • I have put my code.Please have a look. Commented May 5, 2018 at 9:23

1 Answer 1

1

try it

for(int i = 0; i< jsonArray.lenght(); i++){
    double value = jsonArray.getDouble(i);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.