Blog

JSON.parse() Reviver for Dates

Did you know that you can pass a function as the second parameter to JSON.parse()? Doing this causes every key/value pair to be passed to this function for further processing. You can read all about how JSON.parse() and the reviver function works here on MDN’s site. Example Reviver We can Read more…

By Chris West, ago
Blog

JavaScript Snippet – parseJSONC()

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 Read more…

By Chris West, ago