错误字符串无法转换为JsonObject

时间:2012-10-05 05:28:31

标签: 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);
            }
        });

但它显示错误

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

我真的很困惑,任何解决方案?请

2 个答案:

答案 0 :(得分:0)

我正在尝试解析json中的响应,其中响应是xml,我假设。 更好的是,你使用一些XML解析器,比如

  1. SAX Parser
  2. DOM Parser
  3. XMLPULL Parser

答案 1 :(得分:0)

您可能正在尝试将JSON转换为String。尝试使用Gson。它有将JSON转换为字符串

的方法