Fetching data from JSON.parse array

后端 未结 1 1198
不知归路
不知归路 2021-01-25 19:14

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 i

相关标签:
1条回答
  • 2021-01-25 19:27

    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"]);
    
    0 讨论(0)
提交回复
热议问题