« home

Trailing Comma Within JSON's Array

I was debugging an AJAXy app which uses JSON as the data format, and it was fine with Firefox but not with Internet Explorer. After further debugging, the culprit turned out to be trailing commas within the data. {"foo": { "bar": [ {"id": "1", "url": "http://www.hostA.com"}, {"id": "2", "url": "http://www.hostB.com"}, ] }} theObject.foo.bar.length returns 2 in Firefox, but it returns 3 in Internet Explorer. The solution was obviously to remove the last comma.…

more »