Flex deserialization issue with List of Maps

2019-09-08 05:42发布

I have a problem with BlazeDS to Flex mobile deserialization, so that I try to send back list of maps List<Map<String, Object>> with different Objects in every Map, but when I receive this list in flex code:

hastalarim  = event.result as ArrayCollection;

But when I debug this in flex code I see that there're 7 instances of the same Object (the first object that was inserted on server-side) in that list.

Here's my method on server-side:

public List<Map<String, Object>> getHastalarim(String personelId, String servisId) {

        List hastalar =  karDAO.getHastalarim(personelId,servisId);

        Map<String, Object> mp = new HashMap<String, Object>();
        List<Map<String, Object>> lst = new ArrayList<Map<String,Object>>();

        for (int i = 0; i < hastalar.size(); i++) {
            Object[] obj = (Object[]) hastalar.get(i);

            mp.clear();

            mp.put("hastaId", (String) obj[0]);
            mp.put("adi",(String) obj[1]);
            mp.put("soyadi", (String) obj[2]);
            mp.put("tckimlikNo", (String) obj[3]);
            mp.put("yasi", (Integer) obj[4]);
            mp.put("vizitTar", obj[5].toString());          
            mp.put("vizitId", (String) obj[6]);
            mp.put("cinsiyeti", (String) obj[7]);
            mp.put("resim", getHastaResim((String) obj[3]));

            lst.add(mp);

            }
            return lst;
}

What's the problem here? Any suggestions?

1条回答
Fickle 薄情
2楼-- · 2019-09-08 06:25
      for (int i = 0; i < hastalar.size(); i++) {
            Object[] obj = (Object[]) hastalar.get(i);

            Map<String, Object> mp = new HashMap<String, Object>();


            mp.put("hastaId", (String) obj[0]);
            mp.put("adi",(String) obj[1]);
            mp.put("soyadi", (String) obj[2]);
            mp.put("tckimlikNo", (String) obj[3]);
            mp.put("yasi", (Integer) obj[4]);
            mp.put("vizitTar", obj[5].toString());          
            mp.put("vizitId", (String) obj[6]);
            mp.put("cinsiyeti", (String) obj[7]);
            mp.put("resim", getHastaResim((String) obj[3]));

            lst.add(mp);

            }
            return lst;
       }

Create multiple instance of map that is causing the issue.

查看更多
登录 后发表回答