I'm loading a local file that contains a JSON object which has been validated by both jsonlint and freeformater and I'm getting a not well-formed
error in Firefox's console.
I looked at this question and tried to use that but it doesn't seem to work.
This is the text in the file:
{
"CallsStats": [
{
"name": "Sales",
"CallsWaiting": "1",
"OnInboundACDCalls": "0",
"LongestWaitTime": "00:01:14",
"LongestOnHoldTime": "N/A",
"Queue_Interval": {
"name": "CurrentShift",
"CallsAbandoned": "1",
"CallsEntered": "18",
"CallsAnswered": "16",
"AverageWaitTime": "00:01:09",
"AverageHoldTime": "00:00:29",
"AverageTalkTime": "00:03:42"
}
},
{
"name": "Marketing",
"CallsWaiting": "0",
"OnInboundACDCalls": "0",
"LongestWaitTime": "N/A",
"LongestOnHoldTime": "N/A",
"Queue_Interval": {
"name": "CurrentShift",
"CallsAbandoned": "0",
"CallsEntered": "0",
"CallsAnswered": "0",
"AverageWaitTime": "N/A",
"AverageHoldTime": "N/A",
"AverageTalkTime": "N/A"
}
},
{
"name": "Support",
"CallsWaiting": "14",
"OnInboundACDCalls": "14",
"LongestWaitTime": "00:04:42",
"LongestOnHoldTime": "00:02:48",
"Queue_Interval": {
"name": "CurrentShift",
"CallsAbandoned": "816",
"CallsEntered": "2696",
"CallsAnswered": "1349",
"AverageWaitTime": "00:03:36",
"AverageHoldTime": "00:00:13",
"AverageTalkTime": "00:03:27"
}
}
]
}
And this is my code:
function loadJson() {
$(document).ready(function()
{
$.ajax(
{
url: 'sampledata.json',
dataType: 'application/json',
success:function(data) {
console.log(data);
}
}
);
});
}
I don't know if it helps, but this is what the console shows:
I tried before with $.getJSON
and was getting the same result.
EDITS TO THE QUESTION
I tried what James Montagne suggested in the comments (I thought that was the what $.getJSON
would do automatically... And this is what I got:
So I realized that some invisible characters were a problem and I got rid of them.
Now I'm able to load the file as text and convert it to a JSON object using JSON.parse(data)
but still, it shows an error:
What could it be, and should I be concerned?