4 ms·
Why do you call JSON shit? It's incredibly useful and I use it all the time, am I missing something?
by ikt 4y ago
Why do you call JSON shit? It's incredibly useful and I use it all the time, am I missing something?
- shakna 4y agoJSON has a few rough points that make it frustrating to parse. Like for example, most values requiring open and ending tags, no trailing commas allowed (so you must either be lax and non-compliant or backtrack the parser on last element), and other similar edge cases. This results in making it extraordinarily easy to break most parsers in use, today. For example, to kill Python: n="$(python3 -c 'import math; import sys; sys.stdout.write(str(math.floor(sys.getrecursionlimit() - 4)))')" left="$(yes [ | head -n "$n" | tr -d '\n')" echo "$left" | python3 -c 'import json; print(json.loads(input()))' That's a less than 1000-character long object, that can explode. Whilst there are more robust parsers you can get for Python, it doesn't change the fact that generating bad JSON is _easy_. So when you're handling something like email, on a mobile device which may drop a partial connection, you need a hell of a lot of extra work to show the partial download, which might even be everything except the closing braces, or you have to discard the whole thing - which isn't kind to your user.
- duskwuff 4y ago> JSON has a few rough points that make it frustrating to parse. Even so, parsing JSON is a well-understood problem, and there are tons of mature libraries to parse and generate it. I'd much rather work with a JSON-based protocol than one which made up its own wacky data format. The same goes for the use of HTTP. It may not be the ideal protocol for accessing mail, but everyone knows how to work with HTTP, and tools to interact with it are plentiful.
- shakna 4y ago> Even so, parsing JSON is a well-understood problem, and there are tons of mature libraries to parse and generate it. I'd much rather work with a JSON-based protocol than one which made up its own wacky data format. The same could easily be said for mbox and maildir. These have been around forever, and if you have a library for JSON, you've probably got a library for those two, as well. But parsing them tends to be less error-intensive if you hit some kind of connection interruption. The complaint for JSON in JMAP tends to come down to - does it improve the current status quo?
- duskwuff 4y ago> But parsing them tends to be less error-intensive if you hit some kind of connection interruption. Never heard of the ">From" problem? :) mbox has a well-documented escaping problem -- many tools which parse mbox files will mistake a line which begins with the word "from" for the start of a new message. As a result, many tools which generate mbox data will insert a ">" before the start of those lines, mangling the data slightly to prevent corruption. But that's besides the point. mbox/maildir are data storage formats, not network protocols. The corresponding network protocols (POP and IMAP) have their respective problems as well, though.
- shakna 4y agoJSON's not a network protocol, either. It's a data storage format, too. :p Yes, they all have problems. That's... Our industry. You pick and choose your problems. Hence why it's easy to point out rough edges in JSON, and it's easy with mbox or maildir, too.
- addicted 4y agoHow well supported are mbox and maildir relative to JSON? Do you have multiple high quality implementations for supporting mbox or maildir in nearly every language and framework in active use today? If not, then they’re nothing like JSON.
- shakna 4y ago> Do you have multiple high quality implementations for supporting mbox or maildir in nearly every language and framework in active use today? Yes. They're builtin to Python's stdlib [0]. There's dozens for JS. Part of the PHP stdlib. [1] A number for Rust. Several for Go. And so on, and so forth. [0] https://docs.python.org/3/library/mailbox.html https://docs.python.org/3/library/mailbox.html [1] https://www.php.net/manual/en/function.imap-createmailbox.php https://www.php.net/manual/en/function.imap-createmailbox.ph...
- 4y ago
- chrismorgan 4y ago> Its JSON-centred roots and HTTP are conventional, > so special parsers are not needed: this is quite intentional. Two lines from a song rjbs and I made (but never published) about JMAP a few years ago, back when I was a Fastmail employee, set to the tune of the Major-General’s Song.
- calvinmorrison 4y agoI almost always enjoy the faffing around "well I don't like JSON personally therefore it's a bad fit for email" in every one of these threads.
- chrismorgan 4y agoHey, it could be worse. It could be YAML.
- calvinmorrison 4y agoYAMP you mean
- verisimilitudes 4y agoS-expressions are better, and something that sees so much usage should have a dedicated format. In a saner world, this work would already be done so that each protocol needn't define the octets on the line. Regardless, IMAP already exists. It's a diseased mind that takes a shitty programming language, JavaScript, and turns it into a shitty structured data format.
- Gigachad 4y agoNo you aren't missing anything. Most HN users have some weird nostalgia about obsolete technology. Custom protocols and XML are good, JSON is bad because Facebook and Google use it to deliver adverts and it reminds them of Single Page Apps.