I'm using Google App Scripts for retrieve the information of a YouTube page.
I'd managed to retrieve the desired JSON object - embebed in the website's source code, but, after retrieving the JSON object (when I try to parse the JSON), I get the following error:
Uncaught SyntaxError: Invalid or unexpected token
I tried:
- Removing the line breaks - using the regular expressions shown in this page - Remove Line Breaks with Javascript:
- By using
.replace
.
The string value (i.e, the JSON) is a valid one - I've checked it in beautifier.io and jsoneditoronline.org - which contains the formatted JSON data.
This is the jsfiddle with the obtained JSON - the JSON object is too large for add it in the body of my question, hence, the code is available in jsfiddle:
I'm unable to parse the JSON object by code (programatically) - I have to manually remove line breaks.
I can share the code I use for retrieve the JSON object from the website, but, I think the process to get the info is not the main issue, however, if needed, I can post the code.
What other alternatives I have to parse the JSON string in a JSON object (that can be used) programatically?