title: Internet Explorer 10 - jQuery Script 1014: Invalid character when working with JSON - Properly solving it
body: <p>I'm facing the well-known SCRIPT1014 error in IE10 due to the usage of jQuery 1.7.2 JSON.parse. I've been reading several questions in SO about the problem, but the most clear answer I've not found any actually generic response. All what I've found basically says 'check if the data is valid' or 'it might be a bug'.</p>
  
  <p>However, I've found <a href="http://msdn.microsoft.com/en-us/library/ie/cc836466%28v=vs.94%29.aspx" rel="nofollow">this</a> link about this error. It proposes a couple of solutions, but I don't really know how to implement none of them (I don't really know much about JS nor HTML).</p>
  
  <p>This is the piece of code where JSON.parse is invoked:</p>
  
  <pre><code>            var jsonPlaylist;
  
              try {
                  if (window.XMLHttpRequest) {
                      xmlDoc = new window.XMLHttpRequest();
                      xmlDoc.open("GET", 'playlist.xml', false);
                      xmlDoc.send("");
                      jsonPlaylist = xmlToJson(xmlDoc.responseXML);
                  } else if (ActiveXObject("Microsoft.XMLDOM")) {
                      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                      xmlDoc.async = false;
                      xmlDoc.load('playlist.xml');
                      jsonPlaylist = xmlToJson(xmlDoc);
                  }
                  if (window.XMLHttpRequest || ActiveXObject("Microsoft.XMLDOM")) {
                      var str1 = JSON.stringify(jsonPlaylist);
                      var str2 = str1.replace(/{(.*?)\[{"@attributes":{"src"/, '[{"0":{"src"');
                      var str3 = str2.replace(/@attributes/g, '0');
                      var cut = str3.substring(0, str3.length - 2);
                      var ret = JSON.parse(cut);
                      return ret;
                  }
                  alert("Error while loading the playlist.xml file.");
                  return "[0:{src: \'video/default.mp4\', type: \'video/mp4\'}, 0:{src: \'video/default.mp4\', type: \'video/mp4\'}]";
              } catch (err) {
                  return "[0:{src: \'video/default.mp4\', type: \'video/mp4\'}, 0:{src: \'video/default.mp4\', type: \'video/mp4\'}]";
              }
          }
  </code></pre>
  
  <p>And please do not suggest to drop support for IE: It's the only browser with both a reliable support for H.264 and kiosk mode (if anyone knows another browser with these features and it doesn't throw this 1014 thing, I'll be glad to change, though).</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is the logged 'cut':</p>
  
  <pre><code> [{"0":{"src":"video/default.mp4","type":"video/mp4"}},{"0":{"src":"video/default.mp4","type":"video/mp4"}}]
  </code></pre>
  
  <p>And this is the content of playlist.xml, from where 'jsonPlaylist' and, in consequence, 'cut', are generated:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;&lt;playlist&gt;&lt;vid src="video/default.mp4" type="video/mp4"/&gt;&lt;vid src="video/default.mp4" type="video/mp4"/&gt;&lt;/playlist&gt;
  </code></pre>