News for hackers. Stuff that matters.
Re:Debunking the myths about parsing JSON in Swift by jtbrown on Thursday February 18, 2016 @01:36PM (#11128075)
If you're talking about either the bad (pyramid of doom) code in Myth #1 - or the good code there, then it is indeed protecting against null values in the JSON. When you try to cast with `as? String`, it returns nil when there's a null value in the JSON and the code in the `if` block is skipped (and the `else` block is executed if one exists).
Re:Debunking the myths about parsing JSON in Swift by seanalltogether on Thursday February 18, 2016 @05:16PM (#11129770)
The point is that neither of them are good. Nulls should be expected in json objects, so why write the parsing inside a conditional that will fail when one is encountered?