logoalt Hacker News

MrBuddyCasino • yesterday at 11:35 PM • 3 replies • view on HN

JEP 540: Simple JSON API

  > trailing commas and comments are not supported
Be strict in what you produce, be lenient in what you accept. Grr.

Replies

mpyne • today at 12:21 AM

From the JEP's goals: "Provide only those data types and operations required for strict conformance to RFC 8259, in order to facilitate machine-to-machine communication."

In that case they made the right choice, as machines won't be inserting trailing commas or comments in the first place, and the risk of having consuming apps inadvertently accept invalid data would be high otherwise.

chowells • today at 12:22 AM

Fortunately, we now have 50 years of evidence of the negative effects of this philosophy on the ecosystem. Being strict in both results in net positive effects for the entire ecosystem. Trying to be lenient in what you accept results in HTML5, where the exact parse tree for every possible input sequence is specified in order to enforce compatibility. It's no longer lenient, because that doesn't work.

➕ show 1 reply
pixl97 • today at 12:59 AM

This is a great way to ensure you have good application interoperability, but really starts going down hill when you're talking about security and consistency.