遵循代码,
"UserData":[
{
"userid":"8",
"cmp_id":"2",
"token":"VD8iIn0wMSRUVD9dZWxrd1Q\/JWZYeTU6Oz85ZntrMSxhM2x9YWsseVQwfTBkMHhxIlhkOjs\/OWY_",
"first_name":"Rahul ",
"last_name":"Sood",
"username":"Soodcommunication",
"level":"4",
"amount":"0.000000000000000",
"reward_amount":"7.192120767885948",
"identity":"1",
"adhar_uid":"287956228607",
"pan_no":"BHFPS4357H",
"valid_pan":"1",
"verified_pan":"1",
"email":"rahulsood22222@gmail.com",
"mobile":"9736022222",
"create_date":"0000-00-00 00:00:00",
"modify_date":"2016-08-05 16:47:21",
"reff_id":"1",
"collector":"0",
"collector_id":"0",
"tds":"0.000000000000000",
"tax":"0.000000000000000",
"mlm":"485.325000000000000",
"profile_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/profile_8.png",
"adhar_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/adhar_8.png",
"pan_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/pan_8.png",
"caping":"100",
"last_login_time":"2016-08-05 16:47:21",
"last_login_ip":"192.168.0.108",
"last_activity":"2016-07-02 20:21:26",
"auto_login":"1",
"otomax_account":"1",
"reseller_code":"0000",
"allow_otomax_deduct":"1",
"site_feature_request":"1",
"allow_site_features":"1",
"a_mtr_proofs":"0",
"a_pre_paid":"1",
"a_post_paid":"1",
"a_dth":"1",
"a_internet":"1",
"a_mtr":"0",
"a_ebill":"1",
"a_insurance":"1",
"a_datacard":"1",
"gcm_id":null,
"mac_address":"b4:34:54:12:fc:f1",
"imei_number":"911383556485942",
"is_otomax_owner":1
},
{
"userid":"27",
"cmp_id":"2",
"token":"VD8iIn0wMSRUVD9dZWxrd1Q\/JWZYeTU6Oz85ZntrMSxhM2x9YWsseVQwfTBkMHhxIlhkOjs\/OWY_",
"first_name":"Rahul ",
"last_name":"Sood",
"username":"Soodcommunication",
"level":"3",
"amount":"0.000000000000000",
"reward_amount":"0.033380000000000",
"identity":"1",
"adhar_uid":"287956228607",
"pan_no":"BHFPS4357H",
"valid_pan":"1",
"verified_pan":"1",
"email":"rahulsood22222@gmail.com",
"mobile":"9736022222",
"create_date":"0000-00-00 00:00:00",
"modify_date":"2016-08-05 16:47:21",
"reff_id":"8",
"collector":"0",
"collector_id":"0",
"tds":"0.000000000000000",
"tax":"0.000000000000000",
"mlm":"0.000000000000000",
"profile_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/profile_8.png",
"adhar_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/adhar_8.png",
"pan_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/pan_8.png",
"caping":"100",
"last_login_time":"2016-08-05 16:47:21",
"last_login_ip":"192.168.0.108",
"last_activity":"2016-01-04 14:38:31",
"auto_login":"1",
"otomax_account":"1",
"reseller_code":"0000",
"allow_otomax_deduct":"1",
"site_feature_request":"1",
"allow_site_features":"1",
"a_mtr_proofs":"0",
"a_pre_paid":"1",
"a_post_paid":"1",
"a_dth":"1",
"a_internet":"1",
"a_mtr":"0",
"a_ebill":"1",
"a_insurance":"1",
"a_datacard":"1",
"gcm_id":null,
"mac_address":"b4:34:54:12:fc:f1",
"imei_number":"911383556485942",
"is_otomax_owner":1
},
{
"userid":"28",
"cmp_id":"2",
"token":"VD8iIn0wMSRUVD9dZWxrd1Q\/JWZYeTU6Oz85ZntrMSxhM2x9YWsseVQwfTBkMHhxIlhkOjs\/OWY_",
"first_name":"Rahul ",
"last_name":"Sood",
"username":"Soodcommunication",
"level":"2",
"amount":"0.000000000000000",
"reward_amount":"0.422603879502350",
"identity":"1",
"adhar_uid":"287956228607",
"pan_no":"BHFPS4357H",
"valid_pan":"1",
"verified_pan":"1",
"email":"rahulsood22222@gmail.com",
"mobile":"9736022222",
"create_date":"0000-00-00 00:00:00",
"modify_date":"2016-08-05 16:47:21",
"reff_id":"27",
"collector":"0",
"collector_id":"0",
"tds":"0.000000000000000",
"tax":"0.000000000000000",
"mlm":"0.000000000000000",
"profile_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/profile_8.png",
"adhar_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/adhar_8.png",
"pan_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/pan_8.png",
"caping":"100",
"last_login_time":"2016-08-05 16:47:21",
"last_login_ip":"192.168.0.108",
"last_activity":"0000-00-00 00:00:00",
"auto_login":"1",
"otomax_account":"1",
"reseller_code":"0000",
"allow_otomax_deduct":"1",
"site_feature_request":"1",
"allow_site_features":"1",
"a_mtr_proofs":"0",
"a_pre_paid":"1",
"a_post_paid":"1",
"a_dth":"1",
"a_internet":"1",
"a_mtr":"0",
"a_ebill":"1",
"a_insurance":"1",
"a_datacard":"1",
"gcm_id":null,
"mac_address":"b4:34:54:12:fc:f1",
"imei_number":"911383556485942",
"is_otomax_owner":1
},
{
"userid":"29",
"cmp_id":"2",
"token":"VD8iIn0wMSRUVD9dZWxrd1Q\/JWZYeTU6Oz85ZntrMSxhM2x9YWsseVQwfTBkMHhxIlhkOjs\/OWY_",
"first_name":"Rahul ",
"last_name":"Sood",
"username":"Soodcommunication",
"level":"1",
"amount":"50000.000000000000000",
"reward_amount":"0.211391062965119",
"identity":"1",
"adhar_uid":"287956228607",
"pan_no":"BHFPS4357H",
"valid_pan":"1",
"verified_pan":"1",
"email":"rahulsood22222@gmail.com",
"mobile":"9736022222",
"create_date":"0000-00-00 00:00:00",
"modify_date":"2016-08-05 16:47:21",
"reff_id":"28",
"collector":"0",
"collector_id":"0",
"tds":"0.000000000000000",
"tax":"4.335500000000000",
"mlm":"0.000000000000000",
"profile_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/profile_8.png",
"adhar_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/adhar_8.png",
"pan_name":"PROOFS_DATA\/USER_PROOFS\/user_8\/pan_8.png",
"caping":"100",
"last_login_time":"2016-08-05 16:47:21",
"last_login_ip":"192.168.0.108",
"last_activity":"2016-07-01 16:09:03",
"auto_login":"1",
"otomax_account":"1",
"reseller_code":"0000",
"allow_otomax_deduct":"1",
"site_feature_request":"1",
"allow_site_features":"1",
"a_mtr_proofs":"0",
"a_pre_paid":"1",
"a_post_paid":"1",
"a_dth":"1",
"a_internet":"1",
"a_mtr":"0",
"a_ebill":"1",
"a_insurance":"1",
"a_datacard":"1",
"gcm_id":null,
"mac_address":"b4:34:54:12:fc:f1",
"imei_number":"911383556485942",
"is_otomax_owner":1
}
]
答案 0 :(得分:1)
JSONObject jsonObj = new JSONObject("{"+jsonStr+"}");
JSONArray jArray = jsonObj.getJSONArray("UserData");
for(int i = 0; i < jArray.length(); i++)
{
JSONObject object = jArray.getJSONObject(i);
// do some stuff like this....
Toast.makeText(getApplicationContext(),object.getInt("userid"),Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(),object.getString("token"),Toast.LENGTH_LONG).show();
}