0
{
    "0": "261",
    "1": "0",
    "2": "0",
    "3": "",
    "4": "0",
    "5": "0",
    "6": "",
    "7": "<br>",
    "8": "",
    "9": "",
    "10": "",
    "11": "",
    "12": "",
    "13": "",
    "14": "http://www.yandy.com/Seduce-GoGo-Boots.php",
    "15": "2016-01-15 14:44:38",
    "16": "",
    "17": "",
    "18": "2",
    "d_id": "261",
    "m_id": "0",
    "c_id": "0",
    "title": "",
    "price": "0",
    "list_price": "0",
    "descri": "",
    "how_to_get": "<br>",
    "seotitle": "",
    "seokey": "",
    "seometakey": "",
    "seoh1": "",
    "link": "",
    "review": "",
    "image": "http://www.yandy.com/Seduce-GoGo-Boots.php",
    "datetime": "2016-01-15 14:44:38",
    "fp": "",
    "my_title": "",
    "country": "2"
}

that is my code

class LoadAllProducts extends AsyncTask<String, String, String> {

        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(StoreData.this);
            pDialog.setMessage("Loading products. Please wait...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(false);
            pDialog.show();
        }

        /**
         * getting All products from url
         * */
        protected String doInBackground(String... args) {
            // Building Parameters
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            // getting JSON string from URL
            JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);

            // Check your log cat for JSON reponse
            Log.d("All Products: ", json.toString());

            try {
                // Checking for SUCCESS TAG

                Log.d(" i m in try block:",json.toString());


                if (id == 0) {
                    // products found
                    // Getting Array of Products
                     Log.d("in if: ", json.toString());
                      if (json.has("title")) {
                            String projectnumber1 = json.getString("title");
                            Log.d("in if: ", projectnumber1 );
                        }
                      if (json.has("image")) {
                            String projectnumber1 = json.getString("image");
                            Log.d("in if: ", projectnumber1 );
                        }
                      String notes = json.getString("image");
                      store = new JSONArray(notes);
                    //store = json.getJSONArray(TAG_IMAGE);


                    // Check your log cat for JSON response
                    Log.d("Array data: ", store.toString());

                    // looping through All Products
                    for (int i = 0; i < store.length(); i++) {
                        JSONObject c = store.getJSONObject(i);

                        // Storing each json item in variable
                        String image=c.getString(TAG_IMAGE);
                       // String name = c.getString(TAG_TITLE);

                        // creating new HashMap
                        HashMap<String, String> map = new HashMap<String, String>();

                        // adding each child node to HashMap key => value
                        map.put(TAG_IMAGE, image);
                      //  map.put(TAG_TITLE, name);

                        // adding HashList to ArrayList
                        storeList.add(map);
                        Log.d("Array data list: ", storeList.toString());

               }// else {
                    // no products found
                    // Launch Add New product Activity
                   // Intent i = new Intent(getApplicationContext(),
                            //Third.class);
                    // Closing all previous activities
                  //  i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                   // startActivity(i);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }
3
  • 1
    It's jsonObject not jsonArray. Commented Feb 1, 2016 at 7:02
  • what type of error you got it? Commented Feb 1, 2016 at 7:04
  • print all the error stack trace.... Commented Feb 1, 2016 at 7:06

1 Answer 1

1

You're getting image in String variable and trying to convert it into JSONArray at this line

String notes = json.getString("image");
store = new JSONArray(notes);

here notes will be like this "http://www.yandy.com/Seduce-GoGo-Boots.php" and you're converting it to JSONArray. so the error.

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.