Skip to content Skip to sidebar Skip to footer

Fetching Data From Json.parse Array

I am stuck in this problem, I am calling a webService that returns me a json response. now i want to fetch a particular value from that response but after searching on internet and

Solution 1:

The following can be viewed and tested on jsfiddle.net.

// Given a string of JSON called responseText
var responseText = '{"#error":false,"#data":{"sessid":"c4likn6vg33hngbpmobisrsbpcjjmf39","user":{"uid":0,"hostname":"102.119.85.120","roles":{"1":"anonymous user"},"session":"","cache":0}},"#response_code":200}';

// You can parse it to an object using JSON.parse
var responseObj = JSON.parse(responseText);

// And then access the properties as with any object
console.log(responseObj ["#data"]["sessid"]);

Post a Comment for "Fetching Data From Json.parse Array"