Blog

JavaScript – Update HTML Code

Have you ever used JSBin or CodePen and wondered how you can accomplish something like they do on those sites? Of course, CodePen is much more advanced and has more options but if you ever want to combine JavaScript code and CSS code into a full or partial HTML document Read more…

By Chris West, ago
Blog

PHP Snippet – parse_jsonc()

A few months ago I wrote a quick post showing how to parse JSONC (JSON with comments) files in JavaScript. Shortly thereafter I adapted the code to work in PHP as well: This function takes the same arguments that you can pass to the native json_decode() function. Besides removing JavaScript Read more…

By Chris West, ago
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