Home > Software design >  How do I determine where a column is as defined in this JSON error message?
How do I determine where a column is as defined in this JSON error message?

Time:04-19

I am trying to understand how to identify column 26 from this error message

Uncaught SyntaxError: JSON.parse: expected ',' or '}' after property value in object at line 1 column 26 of the JSON data.

This message is derived from the following code

var notedata = JSON.parse('{"results":"<p><img src=\"https:\/\/helpx.adobe.com\/content\/dam\/help\/en\/photoshop\/using\/convert-color-image-black-white\/jcr_content\/main-pars\/before_and_after\/image-before\/Landscape-Color.jpg\" alt=\"Image test\" width=\"702\" height=\"291\"><\/p>\n<p>This is spaghetti. I now have a working bloke section that looks and works better than my previous one. Update3<\/p>"}');

What do they mean by column and how do I determine where a column starts and stops?

CodePudding user response:

In this context, column is read as character.

You need to escape your \ with a double \\

var notedata = JSON.parse('{"results":"<p><img src=\\"https:\/\/helpx.adobe.com\/content\/dam\/help\/en\/photoshop\/using\/convert-color-image-black-white\/jcr_content\/main-pars\/before_and_after\/image-before\/Landscape-Color.jpg\\" alt=\\"Image test\\" width=\\"702\\" height=\\"291\\"><\/p>\\n<p>This is spaghetti. I now have a working bloke section that looks and works better than my previous one. Update3<\/p>"}');
console.log(notedata);

  • Related