2014-09-25 43 views
-1

嘿傢伙我有問題與JSON數組。在我的代碼中,我將手機聯繫人存儲到json數組並將該數組放入一個對象中。但問題在於數組並沒有完全顯示項目,所以它最終顯示了點,以至於json對象是無效的對象。可以幫助我解決以下問題:我的代碼和對象。對象中的JSON數組有171項沒有完全顯示,最後顯示點

 for (PhoneContact phoneContact : phoneContacts) { 
       if (StringUtil.isNotBlank(phoneContact.getContactNumber())) { 
       phoneContact.setStatus("POSTED"); 



     JSONObject object = new JSONObject(); 
       object.put("contactName", phoneContact.getContactName()); 
       object.put("phoneNumber",  
       PhoneUtil.getPhoneNumber(phoneContact.getContactNumber())); 
       JSONObject userobj = new JSONObject(); 
       userobj.put(StringConstant.ID, mapper.getUserId()); 
       // JSONObject groupobj = new JSONObject(); 
       // groupobj.put(StringConstant.ID, groupId); 
       object.put(StringConstant.USER, userobj); 
       // object.put("Group", groupobj); 
       phonenumbers.put(object); 
      } 
     } 
     request.put("contactDetails", phonenumbers); 
     request.put("isSync", Boolean.FALSE); 
    } catch (Exception e) { 
     Log.e(StringConstant.EXCEPTION, e.getMessage()); 
    } 
    return request; 
    } 


    Final JSONObject : 

[ 
{ 
    "phoneNumber": "9822334455", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Sony Ericsson" 
}, 
{ 
    "phoneNumber": "9823145808", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Samsung" 
}, 
{ 
    "phoneNumber": "9822114455", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Inew" 
}, 
{ 
    "phoneNumber": "111", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vodafone Care" 
}, 
{ 
    "phoneNumber": "141", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Balance Info" 
}, 
{ 
    "phoneNumber": "140", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Recharge" 
}, 
{ 
    "phoneNumber": "121", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Best Deal" 
}, 
{ 
    "phoneNumber": "123", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Top Services" 
}, 
{ 
    "phoneNumber": "*444#", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Bonus Cards" 
}, 
{ 
    "phoneNumber": "198", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Complaints Only" 
}, 
{ 
    "phoneNumber": "*111#", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Self Help" 
}, 
{ 
    "phoneNumber": "8421060095", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Pallavi Mother" 
}, 
{ 
    "phoneNumber": "9713344888", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Pintu" 
}, 
{ 
    "phoneNumber": "8421060094", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Sachin Mate" 
}, 
{ 
    "phoneNumber": "9623461238", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Monu" 
}, 
{ 
    "phoneNumber": "9552516847", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Prashant Korde" 
}, 
{ 
    "phoneNumber": "7385863243", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Asiya" 
}, 
{ 
    "phoneNumber": "2024468994", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Pallavi Home" 
}, 
{ 
    "phoneNumber": "8087419790", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Pallavi" 
}, 
{ 
    "phoneNumber": "9730396745", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Narendra" 
}, 
{ 
    "phoneNumber": "8097528780", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Deepak Kumar" 
}, 
{ 
    "phoneNumber": "9732274869", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Jai" 
}, 
{ 
    "phoneNumber": "555555", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vid" 
}, 
{ 
    "phoneNumber": "8087419790", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Palavi" 
}, 
{ 
    "phoneNumber": "88203", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Samtsb3" 
}, 
{ 
    "phoneNumber": "8856903080", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Akash" 
}, 
{ 
    "phoneNumber": "9405681761", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Akash Bar" 
}, 
{ 
    "phoneNumber": "8827394156", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Rajju" 
}, 
{ 
    "phoneNumber": "9730313075", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Kaushal" 
}, 
{ 
    "phoneNumber": "9823054740", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Pandey" 
}, 
{ 
    "phoneNumber": "8888888807", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Banti Landge" 
}, 
{ 
    "phoneNumber": "9890589289", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Shirikant" 
}, 
{ 
    "phoneNumber": "9969320485", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Akhiles Sir" 
}, 
{ 
    "phoneNumber": "9049588154", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Bapu" 
}, 
{ 
    "phoneNumber": "9822387529", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Ehwar Varma" 
}, 
{ 
    "phoneNumber": "7588285442", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vishnu Varma" 
}, 
{ 
    "phoneNumber": "2024489211", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Varma Shop" 
}, 
{ 
    "phoneNumber": "7710002376", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Shoumya" 
}, 
{ 
    "phoneNumber": "9822271444", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Gait Yogesh" 
}, 
{ 
    "phoneNumber": "8087520296", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Grey" 
}, 
{ 
    "phoneNumber": "8796568528", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Deepak" 
}, 
{ 
    "phoneNumber": "8237797002", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Udaram Barsagad" 
}, 
{ 
    "phoneNumber": "8552946297", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Ram Barsagadey" 
}, 
{ 
    "phoneNumber": "8928485985", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vijay Kumar" 
}, 
{ 
    "phoneNumber": "666666", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Celkon" 
}, 
{ 
    "phoneNumber": "9730332839", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vinay" 
}, 
{ 
    "phoneNumber": "8044804480", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Medical" 
}, 
{ 
    "phoneNumber": "9370597136", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Shiris Despande" 
}, 
{ 
    "phoneNumber": "9029013326", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vinay Singh" 
}, 
{ 
    "phoneNumber": "9434824016", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Jai" 
}, 
{ 
    "phoneNumber": "9827023816", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Sushi Tiwari" 
}, 
{ 
    "phoneNumber": "9767718271", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Sachin Iternia" 
}, 
{ 
    "phoneNumber": "9225652817", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Amir LIC" 
}, 
{ 
    "phoneNumber": "9922827717", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Amit Desai" 
}, 
{ 
    "phoneNumber": "9766643946", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Nagesh" 
}, 
{ 
    "phoneNumber": "7709645430", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vijendra" 
}, 
{ 
    "phoneNumber": "9035897140", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Santosh Nigde" 
}, 
{ 
    "phoneNumber": "7766889900", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Test" 
}, 
{ 
    "phoneNumber": "99439209", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Ravi" 
}, 
{ 
    "phoneNumber": "9405984826", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Bandu Mama" 
}, 
{ 
    "phoneNumber": "8087579957", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vaishali" 
}, 
{ 
    "phoneNumber": "9096966100", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Pankaj Kamde" 
}, 
{ 
    "phoneNumber": "9970341902", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Pankaj Kamde 2" 
}, 
{ 
    "phoneNumber": "9421721146", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Ashokh Bhau" 
}, 
{ 
    "phoneNumber": "9822245024", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Shailesh" 
}, 
{ 
    "phoneNumber": "7875011018", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Kuldeep" 
}, 
{ 
    "phoneNumber": "9823338047", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Nagendra Bhange" 
}, 
{ 
    "phoneNumber": "9011096507", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Parik" 
}, 
{ 
    "phoneNumber": "9850831764", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vijay Jadhaw" 
}, 
{ 
    "phoneNumber": "9767511714", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Kamlakar Jadhaw" 
}, 
{ 
    "phoneNumber": "7798205667", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Shebin" 
}, 
{ 
    "phoneNumber": "9623215171", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Iphone Devrlope" 
}, 
{ 
    "phoneNumber": "9039825551", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Jai Mother" 
}, 
{ 
    "phoneNumber": "9545156178", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Prashanth Raghu" 
}, 
{ 
    "phoneNumber": "7506062787", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vijay Shigh" 
}, 
{ 
    "phoneNumber": "9329844710", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Kartik Bhilai" 
}, 
{ 
    "phoneNumber": "9766255660", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Rahul Electroni" 
}, 
{ 
    "phoneNumber": "2060502090", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Gsit Office" 
}, 
{ 
    "phoneNumber": "7276044889", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Shidhrth Plot" 
}, 
{ 
    "phoneNumber": "9527192044", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Ganesh" 
}, 
{ 
    "phoneNumber": "9730079108", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Shailesh Gokhal" 
}, 
{ 
    "phoneNumber": "9892577898", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "You Broadband" 
}, 
{ 
    "phoneNumber": "2024459381", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Woodland Shop" 
}, 
{ 
    "phoneNumber": "7385502166", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Sachin Mate" 
}, 
{ 
    "phoneNumber": "7057474650", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Kamlakar Jadhaw" 
}, 
{ 
    "phoneNumber": "9584618607", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Jai Mother" 
}, 
{ 
    "phoneNumber": "9335344225", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Rani Didi" 
}, 
{ 
    "phoneNumber": "9313643955", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "+919313643955" 
}, 
{ 
    "phoneNumber": "8806312405", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Vijendra Friend" 
}, 
{ 
    "phoneNumber": "9890654329", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Koonal" 
}, 
{ 
    "phoneNumber": "9263586247", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Ravi" 
}, 
{ 
    "phoneNumber": "9860703945", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07dc5f146d" 
    }, 
    "contactName": "Rajesh Patil" 
}, 
{ 
    "phoneNumber": "9763674815", 
    "user": { 
     "id": "13888ff8-25a3-4d4b-a08a-4d07d... 
+0

最終的JSONObject:是結果,你打印在控制檯..我們不能看到完整的響應rt? – 2014-09-25 09:08:05

+0

是的,我無法看到完整的對象 – Yogesh 2014-09-25 09:11:31

+0

我不明白它有什麼問題 – Yogesh 2014-09-25 09:12:14

回答

0
FileOutputStream outputStream; 
try { 
    outputStream = openFileOutput("ur.json", Context.MODE_PRIVATE); 
    outputStream.write("ur file name".getBytes()); 
    outputStream.close(); 
    } catch (Exception e) { 
    e.printStackTrace(); 
    } 

得到JSON從/data/data/urapp/files/ur.json讀取文件。 如果你不想在控制檯中看到它自我然後檢查這個職位string-logcat-will-print