how to parse JSON

how to parse JSON

BY 03 Dec 2014 Web Application Development

Hi,

I have a sample code getting xml output from a http request.

If the call is successful, it calls this :

                if(xhr.status === 200) {
                    success && success(xhr.responseText);
                }

And it  goes to :

    var _requestJson = function(method, url, data, success, failure) {
        var _success = function(data) {
            try {
                data = JSON.parse(data);
            }
            catch(e) {
                failure && failure({ type: 'json', message: e.message });
                return;
            }

            success && success(data);
        };

        if(data !== null) {
            try {
                data = JSON.stringify(data);
            }
            catch(e) {
                failure && failure({ type: 'json', message: e.message });
                return false;
            }
        }

        return _request(method, url, data, _success, failure);
    };

now , how can I get the parsed data ?

I know this seems like a noob question but I really don’t understand this JSON structure and I need to do it quickly for helping a friend. I’d appreciate if anyone could give me an assist.

 

Thanks.

 

Written by