Where The Streets Have No Name

json example - 서버에서 받아오는것 본문

Developement/RIA

json example - 서버에서 받아오는것

highheat 2006. 8. 13. 17:31
        req.setCharacterEncoding("utf-8");
        LBox reqBox = LCollectionUtility.getBox(req);
        GetEmpListTask task = new GetEmpListTask(reqBox.get("user_name"));
       
        //xmlhttp로 받을시 utf-8지정해야 한글이 안깨짐       
        res.setContentType("text/html;charset=UTF-8");
                    
        try{       
            task.perform();
            List empList = task.getList();                     
            PrintWriter out = res.getWriter();
            JSONArray jsonArray = JSONArray.fromArray( empList.toArray() );
            out.println(jsonArray);
            out.close();
        }catch(SysException se){               
            res.sendError(-1,se.getMessage());
            throw se;
        }
        return null;      


clien단

var tmp = eval(originalRequest.responseText);
alert(tmp.length);
alert(tmp[0].userName); //value object의 멤버변수로 접근