public
Last active

JSON parse error

  • Download Gist
gistfile1.txt
1
test-fail.js passes jslint.com, fails jsonlint.com, and fails to parse with Node.js JSON.parse.
test-fail.json
JSON
1 2 3 4 5 6 7
{
"ID3v1": {
"title": "Michael Bolton \'\' Said i lov",
"artist": "Michael Bolton \'\' Said i lov",
"genre": "Blues"
}
}
test-pass.json
JSON
1 2 3 4 5 6 7
{
"ID3v1": {
"title": "Michael Bolton '' Said i lov",
"artist": "Michael Bolton '' Said i lov",
"genre": "Blues"
}
}
test.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
var fs = require('fs');
 
function dbgParse(err, json) {
var data;
 
try {
console.log('input:', json)
data = JSON.parse(json);
console.log('parsed:');
console.log(data);
json = JSON.stringify(data, null, ' ');
console.log('stringified:', json);
data = JSON.parse(json);
} catch (e) {
console.log(e);
}
console.log('\n\n\n');
}
 
fs.readFile('test-pass.json', dbgParse);
fs.readFile('test-fail.json', dbgParse);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.