I am trying to show some JSON data on my website from external URL. When run the script I get this error from the chrome console:
Uncaught SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse ()
Javascript:
var json = $.getJSON("url");
var a = JSON.parse(json.responseText);
var result = a.query.results.rate;
document.write(result[0].Rate);
When I type console.log(result) in the console it returns undefined
JSON:
{
"query": {
    "count": 6,
    "created": "2016-12-21T19:18:22Z",
    "lang": "en-US",
    "diagnostics": {
        "url": [{
                "execution-start-time": "1",
                "execution-stop-time": "2",
                "execution-time": "1",
                "content": "url"
            }, {
                "execution-start-time": "5",
                // more of this
            ]
            "results": {
                "rate": [{
                        "id": "GBPUSD",
                        "Name": "GBP/USD",
                        "Rate": "1.2371",
                    },
                    {
                        "id": "GBPEUR",
                        // more of this
                    },
                }
            ]
        }
I can't make any changes on the JSON file, but I checked it and it is valid.
P.S. When I write the JavaScript code in the chrome console it works.
Thanks in advance.
 
     
     
    