News for hackers. Stuff that matters.
Re:Parsing JSON is a Minefield by s_q_b on Wednesday October 26, 2016 @11:34AM (#12797308)
Yes, exactly this.

What I see a lot is initializing an object from a JSON parser which, when it receives malformed input, either halts execution outright or returns an empty object. In both cases you just want to make sure to handle the error appropriately per-language.

Again, the main offender here is PHP, which makes this issue surprisingly easy to get wrong. (And add "==" to your lint checks! 99% of the time coders mean "===", and this can lead to surprisingly severe security issues.)

Re:Parsing JSON is a Minefield by mikeash on Wednesday October 26, 2016 @11:49AM (#12797461)
If you meant that it would throw or return an error on malformed input, I totally agree. You must always handle errors that your calls might return, and especially when those calls are given anything derived from outside input.
Re:Parsing JSON is a Minefield by s_q_b on Wednesday October 26, 2016 @12:02PM (#12797575)
Yes, generally, and specifically that failure to handle this type of error can cause all sorts of plague, pestilence, and application compromise.
Re:Parsing JSON is a Minefield by mikeash on Wednesday October 26, 2016 @12:07PM (#12797619)
Indeed, forgetting to check for errors is a great way to cause all sorts of terrible bugs. That's one reason I'm starting to become a fan of checked exceptions and result types.