Live data from Hacker News

JSON5 Data Interchange Format

json5.org

91–100 of 157 posts

Re: JSON5 Data Interchange Format

#91
post #52

> "Strings may be single quoted." What's the point? I cringe every time a project uses both double quote and single quote, a mix of semicolon and no semicolon and a mix of tabs and space, .... Which one to pick isn't relevant as soon as the code base is consistent

> What's the point? Some code bases use single quotes, and it's annoying to copy/paste an object from that code into a JSON objdct and have to change the quotes.

prettier solved that

Re: JSON5 Data Interchange Format

#92
post #21

I know it’s not trendy but consider XML and schema at this point. XML allows all this to be expressed and more and schema allows the creation of integration contracts that can be validated at both ends. Tooling and libraries are mature.

The problem is not that XML isn't "trendy". It's annoying to use, especially in an environment where JSON is a first-class citizen. JSON-schema is a thing as well, maybe not quite as mature (or "aged"), but the tooling is fine.

Also massively overengineered.

Re: JSON5 Data Interchange Format

#93
post #15

Earlier quoted context omitted.

Msgpack and protobuf do that too. I believe the rise of JSON is attributed to that it's easily human-readable, and because Javascript.

Not sure human-readability was a major consideration of JSON really, but maybe. One of the major considerations that many seem to miss today though was simplicity of parsing: it's a much more strict syntax than actual JS so there's a lot less ambiguity in parsing it. E.g. there's no need to have layered logic for recognizing unquoted identifiers, no need to check for multiple quote types on IDs & strings, consistent…

Agreed. Every single feature here complicates parsing, and the only two that are worth it IMO are comments and multi-line strings (though I'm sure others disagree on which ones are most important, which is how we end up with something like this)

Re: JSON5 Data Interchange Format

#94
post #57

Earlier quoted context omitted.

It allows you to put double quotes in the string without escaping them, which is pretty nice.

But then you can't include single quotes into the string any more. Same problem again. The most practical solution for this problem I saw was in F#. You can use tripple-quoted strings. let a = """The diner is called "John's", but you can't let the string end with a double quote""" https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe...

I would prefer PostgreSQL-style arbitrary quotes, but with nesting. Something like:

  // the object key here is "weird object key '\""
  {%{weird object key '":}%:"see how it works?"}
  
  // ditto
  {%""{weird object key '":}""%:"see how it works?"}

Re: JSON5 Data Interchange Format

#95
These days, JS has moved on while JSON has remained stuck in the past. There are some fairly important ones it'd be great to get a standard format for in JSON. e.g.

    JSON.stringify({z: 1n})
Also, round tripping ArrayBuffers, Maps, Sets, Symbols and Dates would be really useful. Sadly JSON5 doesn't address those.

I'd quite like a next gen JSON not to get upset on circular references too, although that would most likely require some sort of link or reference data type.

Re: JSON5 Data Interchange Format

#96
post #57

Earlier quoted context omitted.

It allows you to put double quotes in the string without escaping them, which is pretty nice.

But then you can't include single quotes into the string any more. Same problem again. The most practical solution for this problem I saw was in F#. You can use tripple-quoted strings. let a = """The diner is called "John's", but you can't let the string end with a double quote""" https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe...

This is why I like backticks. ` should almost never show up in normal English text.

Re: JSON5 Data Interchange Format

#98

Regardless of how good this is or not, every time it pops up I just wonder if anybody actually gives a crap or not. JSON is one of those formats that's "good enough" even if it's stinky and it's also universally accepted that a small iteration on it with small conveniences doesn't make that much sense imho.

It's true. I doubt this spec will pick up even a little traction either since it's not backwards compatible.

You trade slightly more concrete data structures for hard incompatibility.

Maybe an internal api could leverage this in some way?

But it really isn't that hard to wrap hex, floating points, etc. in quotes and parse that server side.

Any application that's not a pet project should be using json schemas anyways, which is the layer you could put your custom datatypes into.

Re: JSON5 Data Interchange Format

#99
post #57

Earlier quoted context omitted.

But then you can't include single quotes into the string any more. Same problem again. The most practical solution for this problem I saw was in F#. You can use tripple-quoted strings. let a = """The diner is called "John's", but you can't let the string end with a double quote""" https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe...

This is why I like backticks. ` should almost never show up in normal English text.

And, luckily, all transmitted text is normal English.

Re: JSON5 Data Interchange Format

#100

Regardless of how good this is or not, every time it pops up I just wonder if anybody actually gives a crap or not. JSON is one of those formats that's "good enough" even if it's stinky and it's also universally accepted that a small iteration on it with small conveniences doesn't make that much sense imho.

If I had to pick one feature add, it’d be allow trailing commas. That would make serializing a bit easier and less error prone.
Post reply on HN