-
6 Sep 2012 3:52 AM #1
get value from the json list
get value from the json list
Hi all,
I have a json object and in that object contain the list of values.
Suppose code is ,
success: function (response) {
var obj = JSON.stringify(response);
alert(obj);
if function success it return following result-
{"GetAllResult":[{"ID":"5","Name":"Lenny"}]}
Now, i want to get the perticular value like the 'Name' from above list.
So how i can get this?
-
6 Sep 2012 3:57 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
loop through the array with a for loop. Simple JavaScript
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
6 Sep 2012 3:59 AM #3
Hi,
you can try this
alert(obj.GetAllResult.Name);sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
6 Sep 2012 9:25 AM #4
-
7 Sep 2012 12:49 AM #5
hi mitchellsimoens ,
i tried this alert(obj.GetAllResult.Name); but not getting result. getting error of Name undefined.
You say that use for loop , can u give the code of the for loop?
-
7 Sep 2012 2:29 AM #6
Hi,
you can use following code:
Code:success: function (response) { var data = Ext.util.JSON.decode(response.responseText); alert(data.GetAllResult[0].Name); }sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
10 Sep 2012 4:07 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Sep 2012 11:42 PM #8
success: function (response) { var data = Ext.util.JSON.decode(response.responseText); alert(data.GetAllResult[0].Name); }Getting an error - Object [object Object] has no method 'decode'
-
10 Sep 2012 11:44 PM #9


Reply With Quote