如何在Android中使用JSONARRAY检索多条记录

如何在Android中使用JSONARRAY检索多条记录,android,Android,使用下面的代码 Now currently i am getting only updated data of same user by passing id through url. 如何在同一用户的android中显示多个JSONARRAY 例如: [{"id":"46097","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","cre

使用下面的代码

Now currently i am getting only updated data of same user by passing id through url.
如何在同一用户的android中显示多个JSONARRAY

例如:

[{"id":"46097","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","credit":"0","amount":"0","points_mode":"wallet","challan":"","used":"yes","paid_to":"00","pay_type":"0","tranx_id":"One time Sponsorship Charges Deduction","active":"0","created_at":"1497008167","modified_at":"1497008167","tran_count":"3"}]
第二个用户id数组=1066

1st array of user id=1066    [{"id":"46097","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","credit":"0","amount":"0","points_mode":"wallet","challan":"","used":"yes","paid_to":"00","pay_type":"0","tranx_id":"One time Sponsorship Charges Deduction","active":"0","created_at":"1497008167","modified_at":"1497008167","tran_count":"3"}] 

在代码中,只有值被添加到列表中,为什么? 希望jsonStr应该是正确的,并且是正确的

[{"id":"27098","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","credit":"0","amount":"0","points_mode":"wallet","challan":"","used":"no","paid_to":"00","pay_type":"2","tranx_id":"Referral offer","active":"0","created_at":"1492671459","modified_at":"1492671459","tran_count":"2"}]
代码将位于jsonArray的下面。如果是这样,它将被完美地检索。它将以这种形式出现

 JSONArray jr = new JSONArray(jsonStr);
`[{“id”:“46097”,“用户id”:“1066”,“电子邮件”:rahul@gmail.com“,”rolename“:”12“,”账号“:”3445557752334556“,”借方“:”0“,”贷方“,”金额“,”0“,”积分模式“,”钱包“,”challan“,”使用“:”是“,”付款对象“:”00“,”付款类型“:”0“,”交易id“:”一次性赞助费扣除“,”活动“:”0“,”创建时间“:”1497008167“,”修改时间“:”1497008167”,“tran_count”:“3”},
{“id”:“27098”,“用户id”:“1066”,“电子邮件”:rahul@gmail.com“,”rolename“:”12“,”账号“:”3445557752334556“,”借方“:”0“,”贷方“,”金额“:”0“,”积分模式“,”钱包“,”challan“,”使用“:”否“,”付款对象“:”00“,”付款类型“:”2“,”交易id“:”转介报价“,”活动“:”0“,”创建地址“:”1492671459“,”修改地址“:”1492671459“,”交易计数“:”2”,]
在代码中,而不是

`[{"id":"46097","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","credit":"0","amount":"0","points_mode":"wallet","challan":"","used":"yes","paid_to":"00","pay_type":"0","tranx_id":"One` time Sponsorship Charges Deduction","active":"0","created_at":"1497008167","modified_at":"1497008167","tran_count":"3"},
     {"id":"27098","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","credit":"0","amount":"0","points_mode":"wallet","challan":"","used":"no","paid_to":"00","pay_type":"2","tranx_id":"Referral offer","active":"0","created_at":"1492671459","modified_at":"1492671459","tran_count":"2"},<another value>] 

for(i=0;i什么是多条记录?多条记录意味着用户的多个数组信息(第一个数组,第二个数组…..n-array)谢谢你的回复…我尝试了(i=0;i最初我尝试在列表中显示,因此添加到列表中…。但是列表是nt问题,问题是nt显示多个JSONArray,例如(i=0;i显示jsonStr并检查它是否为正确的json格式。使用可以检查它。如果它有效,JSONArray jr=new JSONArray(jsonStr)当然有适当的JSONArray,在这种情况下,jr.length()将完美地工作
`[{"id":"46097","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","credit":"0","amount":"0","points_mode":"wallet","challan":"","used":"yes","paid_to":"00","pay_type":"0","tranx_id":"One` time Sponsorship Charges Deduction","active":"0","created_at":"1497008167","modified_at":"1497008167","tran_count":"3"},
     {"id":"27098","user_id":"1066","email":"rahul@gmail.com","rolename":"12","account_no":"3445557752334556","debit":"0","credit":"0","amount":"0","points_mode":"wallet","challan":"","used":"no","paid_to":"00","pay_type":"2","tranx_id":"Referral offer","active":"0","created_at":"1492671459","modified_at":"1492671459","tran_count":"2"},<another value>] 
  for(i=0;i<3;i++) {
    please change to
    for(i=0;i<jr.length();i++) {  //as till the last jsonarray it will traverse.