I have an application that runs inside of a viewer that forces the app to run in IE8 compatability mode. I understand IE 8 is not longer supported by Microsoft and it is a very bad browser, but it is a limitation that I have to deal with since I have no control over my Viewer. I am trying to convert an object into json string.
Here is what I have done so far. First, I create JavaScript object like this
var records = {};
records['123'] = {};
records['456'] = {};
records['123']['rec_id'] = 4456;
records['123']['created_at'] = getCurrentTime();
records['123']['assigned_at'] = getCurrentTime();
records['123']['sys_id'] = 1745;
records['456']['rec_id'] = 4456;
records['456']['created_at'] = getCurrentTime();
records['456']['assigned_at'] = getCurrentTime();
records['456']['sys_id'] = 1745;
$.each(records, function(callID, record){
record['campaign_id'] = '1';
record['offset'] = getCurrentOffset();
record['attempt'] = '7';
record['phone'] = '800-123-4567';
record['identity'] = 123;
record['code'] = 'Some Code';
record['notes'] = 'Some notes';
record['completed_by'] = 'Mike A';
record['name'] = 'Mike A';
record['completed_at'] = getCurrentTime();
});
Now, I want to convert my records object into json string.
In modern browsers I can use JSON.stringify() to convert the object with no problem. However, JSON.stringify()
does not work in IE 8 compatability mode.
I found alternative solution to convert the object into json string jQuery JSON plugin
I tried to convert my object using jQuery JSON plugin like so
$.toJSON(records);
But, that is giving me the following error
Line: 116
Error: Invalid procedure call or argument
URL: copy of the code in this URL https://github.com/Krinkle/jquery-json/blob/master/src/jquery.json.js
How can I convert my object into JSON string? am I defining my object incorrectly or is there something else that I need to do to get the object converted?