[英]Error String cannot be converted to JsonObject
I have code to show store like this . 我有代码来显示这样的商店。 and i still learning about android , 而且我仍然在学习android,
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String pid = ((TextView) view.findViewById(R.id.id_store)).getText()
.toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(),
editstoreActivity.class);
// sending pid to next activity
in.putExtra("phone", mPhoneNumber);
in.putExtra(TAG_PID, pid);
// starting new activity and expecting some response back
startActivityForResult(in, 100);
}
});
but it show error like this 但它显示这样的错误
10-05 12:17:56.149: INFO/ActivityManager(59): Starting activity: Intent { cmp=shoop3.android.edu/.editstoreActivity (has extras) }
10-05 12:17:58.289: DEBUG/dalvikvm(957): GC_FOR_MALLOC freed 1530 objects / 274448 bytes in 208ms
10-05 12:17:59.649: ERROR/JSON Parser(957): Error parsing data org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
10-05 12:17:59.669: DEBUG/Single Store Details(957): {"store":[{"id_user":"63","id_platform":"1","store_url":"url.com","store_desc":"wordpress","id_store":"42","store_logo":null,"store_name":"toko wordpress edit","store_curr":null},{"id_user":"63","id_platform":"2","store_url":"pres.com","store_desc":"prestashop","id_store":"43","store_logo":null,"store_name":"toko prestashop","store_curr":null}]}
10-05 12:18:00.899: INFO/ActivityManager(59): Displayed activity shoop3.android.edu/.editstoreActivity: 4664 ms (total 4664 ms)
10-05 12:18:58.339: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol
10-05 12:23:58.343: DEBUG/SntpClient(59): request time failed: java.net.SocketException: Address family not supported by protocol
I really confuse , any solution?? 我真的很困惑,任何解决方案? please 请
You are trying to parse response in json, where response is in xml, I assume. 我想您正在尝试解析json中的响应,其中响应位于xml中。 Better, you use some XML parser, like 更好的是,您使用一些XML解析器,例如
You are possibly trying to convert a JSON to String . 您可能正在尝试将JSON转换为String。 Try using Gson . 尝试使用Gson。 It has methods to convert the JSON to string 它具有将JSON转换为字符串的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.