Remix.run Logo
▲ brunoborges 3 hours ago

> "JavaScript Object Notation (JSON) is a simple data interchange format [...]"

Clearly it isn't, otherwise every language would have sorted it out by... a long time ago.

▲yubblegum 25 minutes ago | parent | next [-]

Meet the "Simple Object Access Protocol": https://www.w3.org/TR/2000/NOTE-SOAP-20000508/

▲ivanjermakov 19 minutes ago | parent | prev | next [-]

Simple data format does not imply that API to work with it is easy to get right.

▲kccqzy 2 hours ago | parent | prev | next [-]

Some languages have a culture of doing things correctly and conforming strictly to the spec. These languages have indeed sorted it out years ago. Haskell for example. Any language that doesn’t have a special number type for JSON is a half-assed implementation, because 1e1000 is a perfectly valid JSON number that is beyond the typical IEEE754 double precision floating point numbers; does your language handle that correctly? Haskell does. This is but a small example of a strong culture bias towards correctness.

▲layer8 an hour ago | parent | next [-]

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.

▲ncruces an hour ago | parent | prev [-]

Ironically Go has(d) json.Number which almost no one used, so it got dropped from v2: https://pkg.go.dev/encoding/json#Number

You can still use it though, and I built my tiny decimal library around it: https://github.com/ncruces/decimal

▲jayd16 2 hours ago | parent | prev [-]

Ok so nothing is simple then?