Last year I needed a way to be able to parse JSON with comments (also known as JSONC). With that in mind I wrote the following short solution which will essentially remove JavaScript-style comments and trailing commas from the specified JSONC string and then the native JSON.parse() function will parse the remaining string:

Feel free to try this parseJSONC() function out yourself and let me know what you think. As always, happy coding! šŸ˜Ž

Categories: BlogJavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *