地图列表的 Flex 反序列化问题 [英] Flex deserialization issue with List of Maps

查看:22
本文介绍了地图列表的 Flex 反序列化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 BlazeDS 到 Flex 移动反序列化时遇到问题,因此我尝试发送回地图列表 List> 与每个 Map 中的不同对象,但是当我在 flex 代码中收到此列表:

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;

但是当我在 flex 代码中调试它时,我看到该列表中有 7 个相同对象(在服务器端插入的第一个对象)的实例.

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?

推荐答案

      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.

这篇关于地图列表的 Flex 反序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆