Re:Parsing JSON is a Minefield
by IshKebab on Sunday April 22, 2018 @05:02PM
(#16898565)
Most of the things they test are true of any text-based format, and many of them are true of any serialisation format. E.g. 100000 opening brackets. You could do the same in XML for example and I expect many parsers would fail.
[ Parent
| on HN ]
Maybe the difference is that nobody ever thought that XML was easy to parse.
Re:Parsing JSON is a Minefield
by SamReidHughes on Sunday April 22, 2018 @10:51PM
(#16900160)
XML is far worse than JSON, it is known. It's a lot easier to screw up a text based format than a binary format. But it would also be possible to make a better text based format than JSON, mainly by defining down what numerical values are allowed to be represented and exactly how they get parsed, and making it harder to screw up strings. That's where most of the problems are.
I think the reason JSON doesn't take well to strong typing is that it is designed for Javascript. When you pass some Javascript object to the JSON encoder how is it supposed to decide which numeric representation to use? Does it always go for the smallest one that works? The Javascript decoder at the other end is just going to throw away that type information anyway, so all it is good for is verifying the data while you are parsing it. Maybe not a totally useless thing to do but it's a lot of work to get that modest benefit.
Re:Parsing JSON is a Minefield
by SamReidHughes on Monday April 23, 2018 @02:45AM
(#16901016)
Making an encoding tailored to JavaScript documents that is a binary format is easy. And I don't think strong typing has anything to do with it. Making it handle Python and Ruby objects at the same time is harder, because they have different opinions about what a string is, what a number can be.