> "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.
JSON5 Data Interchange Format
91–100 of 157 posts
Re: JSON5 Data Interchange Format
#92I 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.
Re: JSON5 Data Interchange Format
#93Earlier 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…
Re: JSON5 Data Interchange Format
#94Earlier 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...
// 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 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
#96Earlier 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...
Re: JSON5 Data Interchange Format
#97Re: JSON5 Data Interchange Format
#98Regardless 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.
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
#99Earlier 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.
Re: JSON5 Data Interchange Format
#100Regardless 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.