logoalt Hacker News

layer8 • yesterday at 11:24 PM • 1 reply • view on HN

The spec (RFC 8259) leaves significant leeway to implementations:

A JSON parser MAY accept non-JSON forms or extensions.

An implementation may set limits on the size of texts that it accepts. An implementation may set limits on the maximum depth of nesting. An implementation may set limits on the range and precision of numbers. An implementation may set limits on the length and character contents of strings.

Add to that things like duplicate keys being allowed by the spec. There’s a lot of implementation choices to decide on.

And then things can get really complex with JSON Schema.


Replies

kccqzy • today at 12:42 AM

Yeah that’s what I mean by strictly. Does your implementation take shortcuts or does it hold itself to a higher standard and not do that? Does it only use available memory as the ultimate limit?

A lot of specs contain these optional limitations. The C standard allowed implementations to truncate variable names to 31 characters if they have external linkage and 63 if internal linkage. Would you be happy if your implementation actually does that? Of course not. Neither LLVM nor GCC does that. That’s because people writing compilers also hold themselves to a higher standard. Now imagine this kind of attitude being pervasive.

➕ show 2 replies