Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
58
rated 0 times [  63] [ 5]  / answers: 1 / hits: 81332  / 13 Years ago, tue, march 6, 2012, 12:00:00

Hi. I got my output in JSON... Now I need to convert those data into javascript..



How to write the code in javascript?
I have to display the images to the browser.. it is possible only by writing the code in javascript.
Help me..



My JSON output is..



    [{0:101,member_id:101,1:3k.png,image_nm:3k.png,2:/images/phones/,image_path:/images/phones/},
{0:102,member_id:102,1:mirchi.png,image_nm:mirchi.png,2:images/phones/,image_path:images/phones/},
{0:103,member_id:103,1:masti.png,image_nm:masti.png,2:images/phones/,image_path:images/phones/}]

More From » json

 Answers
231

hai i got my output in JSON...now i need to convert those data into
javascript..




Use JSON.parse() function in order to convert it to JS object.



var obj = JSON.parse(yourJsonString);


And now you can use for-in loop to iterate over each of its items:



for (var x in obj){
if (obj.hasOwnProperty(x)){
// your code
}
}

[#87035] Saturday, March 3, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
payne

Total Points: 527
Total Questions: 108
Total Answers: 88

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;