Follow

The JSON spec asks for whitespace after {, [ and before and after the value, but every JSON validator don't need whitespaces to consider a JSON valid and I've never seen a non-prettified JSON with whitespaces. It doesn't say they are optional, even though they clearly don't need to be there.

· · Web · 4 · 1 · 7

@sevvie I was quite surprised too, but I guess it makes sense since it's supposed to be human readable

@sevvie @matrix

@matrix

Yes, it does say that they are optional:

-------------
Insignificant whitespace is allowed before or after any of the six
structural characters.

ws = *(
%x20 / ; Space
%x09 / ; Horizontal tab
%x0A / ; Line feed or New line
%x0D ; Carriage return
)
---------------

"allowed", not required.

@matrix don't forget that comments are not allowed in JSON.

Since you need to be able to put comments into JSON sometimes, a lot of parsers will allow JavaScript style comments.

@matrix@gameliberty.club I wonder if this was added specifically for some known buggy implementation at the time

@matrix isn't "whitespace" as the grammar element defined as optionally nothing?
@Ukko @matrix depends
some whitespace is optional while some aren't, depends on language and situation
for example variable declaration in c requires whitespace
@Ukko @matrix also i 100% thought i was replying to maija, pfp way too similar
Sign in to participate in the conversation
Game Liberty Mastodon

Mainly gaming/nerd instance for people who value free speech. Everyone is welcome.