Tuesday, 10 September 2013

How to fetch Data from Json object in javascript?

How to fetch Data from Json object in javascript?

I am working on SpringMVC in my controller i am create one Json object and
i passed that object to javascript But How can i read that object in
javascript any One help me Please check My code
My Map object
Map<String rootNode,List<String>> map = new HashMap<String
rootNode,List<String>();
String rootNode = "bhanu";
ArrayList<String> al = new ArrayList<String>();
for(int i=0;i<UserProfile.size;i++)
{
al.add(userProfile.get(i));
}
map.put(userProfile,al);
At last my Map object have this Data
{"Bhanu":["hari@gmail.com","balu@gmail.com","santha@gmail.com"],"root":["bhanu@gmail.com","anu@gmail.com","apar@gmail.com"],"hari":["bhanuprasad@gmail.com","sravya@gmail.com","mahesh@gmail.com"],"balu":["rama@gmail.com"]}
Now i convert this object into GSon
Gson gson = new GSon();
String orgChartUsers = gson.toJson(map);
Now i passed this String into my javascript
Because this is my Ajax Response.. function orgUsers(result) {
var orgObject = JSON.parse(result);
//Here i can i fetch my List<String> data
}
Any one help me how can i do this...

No comments:

Post a Comment