Error parsing data org.json.JSONException: End of input at character 0 of

后端 未结 1 592
野趣味
野趣味 2021-01-27 12:22

I got the error when to parse the JSON. Error parsing data org.json.JSONException: End of input at character 0 of.

error log:

04-19 20:51:00.635: E/View         


        
相关标签:
1条回答
  • 2021-01-27 12:57

    DONE!!! After referring to Passing String array to PHP as POST I got the answer.

    /**
    * Function store order details
    **/
    public JSONObject orderDetails(String username, String[] pid, String[] products,    String[] quantity, String[] totalprice, String finalprice) {
    // Building Parameters
    List params = new ArrayList();
    params.add(new BasicNameValuePair("tag", order_tag));
    params.add(new BasicNameValuePair("username", username));
    params.add(new BasicNameValuePair("finalpice", finalprice));
    for (int i = 0; i < pid.length; i++) {
        params.add(new BasicNameValuePair("pid[]", pid[i]));
    }   
    for (int j = 0; j < products.length; j++) {
        params.add(new BasicNameValuePair("products[]", products[j]));
    }
    for (int k = 0; k < quantity.length; k++) {
        params.add(new BasicNameValuePair("quantity[]", quantity[k]));
    }
    for (int l = 0; l < totalprice.length; l++) {
        params.add(new BasicNameValuePair("totalprice[]", totalprice[l]));
    }
    
    JSONObject json = jsonParser.getJSONFromUrl(orderURL,params);
    return json;
    } 
    
    0 讨论(0)
提交回复
热议问题