我的代碼發佈在服務器中的數據, 這是我的代碼值<java.lang.String類型的DIV不能被轉換爲JSONObject的
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("phone", mPhoneNumber));
params.add(new BasicNameValuePair("prod_title", nama));
params.add(new BasicNameValuePair("prod_desc", des));
JSONObject json = jsonParser.makeHttpRequest(Constants.url_create_product, "POST", params);
// check log cat from response
Log.d("Create Response", json.toString());
try {
int success = json.getInt(Constants.TAG_SUCCESS);
if (success == 1) {
// successfully created user
Intent i = new Intent(getApplicationContext(), shoop3Activity.class);
i.putExtra("phone", mPhoneNumber);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create user
Toast.makeText(getApplicationContext(),"Gagal bikin user", Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
,但它顯示的錯誤這樣
10-08 12:36:11.857: INFO/ActivityManager(59): Displayed activity shoop3.android.edu/.Activity3: 1074 ms (total 1074 ms)
10-08 12:36:16.037: ERROR/JSON Parser(881): Error parsing data org.json.JSONException: Value <div of type java.lang.String cannot be converted to JSONObject
10-08 12:36:16.037: DEBUG/Create Response(881): {"status":1}
10-08 12:36:16.127: INFO/ActivityManager(59): Starting activity: Intent { cmp=shoop3.android.edu/.setupstoreActivity (has extras) }
10-08 12:36:17.507: INFO/ActivityManager(59): Displayed activity shoop3.android.edu/.setupstoreActivity: 1191 ms (total 1191 ms)
任何解決方案,please???它顯示錯誤解析數據...字符串不能轉換爲JSonObject
是的,它發生在我身上,我將錯誤的值傳遞給我的一個參數。我幾乎沒有想到這一點。 –