2017-05-27 156 views
0

字符275對象未結束我的代碼已經得到網站的數據(jsonstr),但不能使它到的JSONObject並使其錯誤JSON解析錯誤:未結束的對象人品2755JSON解析錯誤:在

protected Void doInBackground(Void... arg0) { 
      HttpHandler sh = new HttpHandler(); 

      // Making a request to url and getting response 
      String jsonStr = sh.makeServiceCall(url); 

      Log.e(TAG, "Response from url: " + jsonStr); 

      if (jsonStr != null) { 
       try { 
        JSONObject jsonObj = new JSONObject(jsonStr); 

        // Getting JSON Array node 
        JSONArray contacts = jsonObj.getJSONArray("Destinasi"); 

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

         String nim = c.getString("nama_destinasi"); 
         String name = c.getString("alamat_destinasi"); 
         String alamat= c.getString("deskripsi_destinasi"); 

而這個鏈接,我嘗試分析 https://ombajuom.000webhostapp.com/json_destinasi.php/Destinasi

請幫助我,對不起我的英語

回答

1

我看到一個錯位的]} in JSON String。該字符串返回NOW如下

{ 
    "Destinasi": [ 
     { 
     "nomor_id": "1", 
     "nama_destinasi": "Ravi Tamada", 
     "alamat_destinasi": "Ciledug", 
     "deskripsi_destinasi": "WAhhh", 
     "rating_destinasi": "3" 
     ] 
    } 
} 

但應如下使它成爲一個有效的JSON。您共享

{ 
    "Destinasi": [ 
     { 
     "nomor_id": "1", 
     "nama_destinasi": "Ravi Tamada", 
     "alamat_destinasi": "Ciledug", 
     "deskripsi_destinasi": "WAhhh", 
     "rating_destinasi": "3" 
     } 
    ] 
} 
+0

我知道了,謝謝它的工作 –

0

Web服務是不是一個有效的JSON格式,來驗證你的迴應,你可以使用jsonlint.com,

感謝

+0

謝謝jsonlint.com是新的信息給我 –