I'm currently working on a web scraper and I'm getting the JSON from <script type="application/ld+json> on a particular web page. I get it as a string using Cheerio and pass it on a JSON parser (npm package). But I keep on getting a syntax error and this happens if the value has a trailing white space.
I tried the reviver by trimming each value but it still doesn't work.
This is a snippet of my JSON string where I get a Syntax Error:
{"...821", "description":" \r\n
","@type":"Organization",...}
This is the error that I'm getting:
ErrorEXError [JSONError]: Unexpected token in JSON at position 1432 while parsing near '...821","description":" \r\n ","...'
How can I trim the description value without string manipulation?
without string manipulation?Huh? You'll have to manipulate the string somehow in order to change it to make it parseable, what do you mean?