Live data from Hacker News

JSON5 Data Interchange Format

json5.org

41–50 of 157 posts

Re: JSON5 Data Interchange Format

#41
A JSON5 parser comes in handy for scraping, when you want to extract data that is embedded directly inside the javascript source of a website.

But I wouldn't ever use JSON5 over JSON for serialization, or over YAML for parsing a configuration file.

Re: JSON5 Data Interchange Format

#43

> "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

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

What if you want both?

E.g., how would you put the following sentence in a string:

You can use both " and ' to delimit a string.

Re: JSON5 Data Interchange Format

#44
post #36
post #29

Earlier quoted context omitted.

Json is not meant to be human readable or writeable.

All text based data formats are meant to be human readable and human writable, and humans read and write JSON all the time.

You wouldn't say that mammals write C all the time, would you? Front end development would be so much better if you could just spew json at people in a table.

Re: JSON5 Data Interchange Format

#45
post #43

Earlier quoted context omitted.

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

What if you want both? E.g., how would you put the following sentence in a string: You can use both " and ' to delimit a string.

You'd use escapes:

"You can use both \" and ' to delimit a string"

Re: JSON5 Data Interchange Format

#46
post #11

Earlier quoted context omitted.

Because: ‘I am “really” angry’ Is much nicer than: “I am \”really\” angry”

and now you have two problems is this any better? 'I\'m "really" angry, don\'t do it again!' in many languages single quotes are used as apostrophes and are very very common, much more common than double quotes.

Nobody's forcing you to use single quotes as delimiters.

"I'm \"really\" angry, don't do it again!"

Re: JSON5 Data Interchange Format

#47

I'd love if they added support for dates, e.g. { justDate: @2020-02-08 } { dateAndTime: @2007-03-01T13:00:00Z } { justTime: @@13:00:00 }

Well, that has nothing to do with "Javascript" notation So first get that kind of notation into javascript, then wait 15 years

Re: JSON5 Data Interchange Format

#48
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.

Re: JSON5 Data Interchange Format

#49

> "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

Getting over your pet peeves is a superpower.

Re: JSON5 Data Interchange Format

#50
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.

XML is a terrible data interchange format because it embeds its schema in its data. That makes it sometimes an order of magnitude larger, and it takes longer to parse.

If you want to drop JSON altogether, something like Protobufs would be better. But JSON + JSONSchema has all the benefits of XML and none of the drawbacks.

Post reply on HN