Getting Only First Object Of Json Object From Json String
Solution 1:
Convert the string in a JsonArray.
JSONArray jsonArray = newJSONArray(str);
then use the below code.
JsonObject jsonObject;
for (int i = 0; i < jsonArray.length(); i++) {
jsonObject = jsonArray.getJSONObject(i);
}
Solution 2:
It is a malformed JSON,
the correct one would be like this:
[
{
"emp_remark": "right now busy.. please wait",
"emp_loginid": "pra",
"emp_name": "Pragya Patel",
"emp_timein": "18:9",
"emp_id": "1",
"emp_timeout": "18:9",
"emp_emailid": "hsjsnejw",
"emp_mobno": "7879467946",
"emp_desigantion": "Android",
"emp_deviceid": "APA91bFLNsLOz2iiSw9r2NKdlnWCWtNNNb-VTVY3TwmT7Nly88NnSJjJwoLNC3qveU7LSW9QY5t71JAejnkogvQRPXA-uEtnlg-1cve00k_4UhIinUH0Lzs"
},
{
"emp_remark": "right now busy.. please wait",
"emp_loginid": "deepp",
"emp_name": "deepak",
"emp_timein": "18:18",
"emp_id": "2",
"emp_timeout": "18:9",
"emp_emailid": "deep@gmail.com",
"emp_mobno": "7469467946",
"emp_desigantion": "java",
"emp_deviceid": null
},
{
"emp_remark": "right now busy.. please wait",
"emp_loginid": "amu",
"emp_name": "amul",
"emp_timein": "18:18",
"emp_id": "3",
"emp_timeout": "18:9",
"emp_emailid": "amu@gmail.com",
"emp_mobno": "7469462946",
"emp_desigantion": "java",
"emp_deviceid": "APA91bFLNsLOz2iiSw9r2NKdlnWCWtNNNb-VTVY3TwmT7Nly88NnSJjJwoLNC3qveU7LSW9QY5t71JAejnkogvQRPXA-uEtnlg-1cve00k_4UhIinUH0Lzs"
}
]
Solution 3:
I think it's not a normal jsonList like [{a:"1",b:"2"},{c:"3",d:"4"}],so you can only get first object. object like this:{key,value} list like this:[collection, collection]
Post a Comment for "Getting Only First Object Of Json Object From Json String"