this post was submitted on 20 Dec 2024
974 points (96.9% liked)

Programmer Humor

32751 readers
75 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] masterspace@lemmy.ca 0 points 6 days ago* (last edited 6 days ago) (4 children)

It will cause casting errors in other languages that have badly written, non-standards compliant, JSON parsers, as 1 and 1.0 being the same is part of the official JSON ISO standard and has been for a long time: https://json-schema.org/understanding-json-schema/reference/numeric

[–] tyler@programming.dev 0 points 5 days ago* (last edited 5 days ago) (3 children)

JSON schema is not a standard lol. 😂 it especially isn’t a standard across languages. And it most definitely isn’t an ISO standard 🤣. JSON Data Interchange Format is a standard, but it wasn’t published until 2017, and it doesn’t say anything about 1.0 needs to auto cast to 1 (because that would be fucking idiotic). https://datatracker.ietf.org/doc/html/rfc8259

JSON Schema does have a draft in the IETF right now, but JSON Schema isn’t a specification of the language, it’s for defining a schema for your code. https://datatracker.ietf.org/doc/draft-handrews-json-schema/

Edit: and to add to that, JavaScript has a habit of declaring their dumb bugs as “it’s in the spec” years after the fact. Just because it’s in the spec doesn’t mean it’s not a bug and just because it’s in the spec doesn’t mean everywhere else is incorrect.

[–] masterspace@lemmy.ca 0 points 5 days ago* (last edited 5 days ago) (2 children)

Yes, it most literally and inarguably is:

https://www.iso.org/standard/71616.html

Page 3 of INTERNATIONAL STANDARD

  • ISO/IEC 21778 - Information technology — The JSON data interchange syntax

8 Numbers A number is a sequence of decimal digits with no superfluous leading zero. It may have a preceding minus sign (U+002D). It may have a fractional part prefixed by a decimal point (U+002E). It may have an exponent, prefixed by e (U+0065) or E (U+0045) and optionally + (U+002B) or – (U+002D). The digits are the code points U+0030 through U+0039.

[–] barubary@infosec.exchange 0 points 5 days ago

That confirms exactly what tyler said. I'm not sure if you're misreading replies to your posts or misreading your own posts, but I think you're really missing the point.

Let's go through it point by point.

  • tyler said "JSON Schema is not an ISO standard". As far as I can tell, this is true, and you have not presented any evidence to the contrary.

  • tyler said "JSON Data Interchange Format is a standard, but it wasn’t published until 2017, and it doesn’t say anything about 1.0 needs to auto cast to 1". This is true and confirmed by your own link, which is a standard from 2017 that declares compatibility with RFC 8259 (tyler's link) and doesn't say anything about autocasting 1.0 to 0 (because that's semantics, and your ISO standard only describes syntax).

  • tyler said "JSON Schema isn’t a specification of the language, it’s for defining a schema for your code", which is true (and you haven't disputed it).

Your response starts with "yes it is", but it's unclear what part you're disagreeing with, because your own link agrees with pretty much everything tyler said.

Even the part of the standard you're explicitly quoting does not say anything about 1.0 and 1 being the same number.

Why did you bring up JSON Schema (by linking to their website) in the first place? Were you just confused about the difference between JSON in general and JSON Schema?

load more comments (1 replies)
load more comments (1 replies)
load more comments (1 replies)