4 ms·
JSON5 supports comments, and is only slightly more complex than JSON. https://json5.org/ https://json5.org/
by tlb 8y ago
JSON5 supports comments, and is only slightly more complex than JSON. https://json5.org/ https://json5.org/
- outworlder 8y agoMost parsers will not support JSON5.
- nostalgeek 8y agoMore like browsers can de-serialize JSON5 natively. writing a JSON5 parser is not difficult. It's just not part of most std libs in most languages, but I would argue that most std libs don't parse YAML either. JSON5 is a good compromise.
- tlb 8y agoNeither Chrome nor Firefox's JSON.parse accept JSON5. I'm not sure what browser API you mean. For example, JSON.parse(`{"foo":"bar",}`) throws a syntax error.
- nostalgeek 8y ago> Neither Chrome nor Firefox's JSON.parse accept JSON5. I'm not sure what browser API you mean. This is a typo, I meant "can't" not "can". Off course browsers don't support JSON5 or my message makes no sense whatsoever.
- saghm 8y agoThe barrier here would be whether there's support in enough implementations to feel safe using it in the wild, which I'm guessing will take a while at the very least.
- tajen 8y agoWhat’s incredible here is that we’re not at the beginning of programming, when we built temporary languages that ended up becoming forgotten. Web may be a final form of IT, Angular may be the « right », the final, the perfect way to build applications even in 50 years, just like HTML has become the final way to build websites for the last 25 years, JSON may make legacy, and my grandson might even struggle with parsers that still use JSON instead of this new tech called JSON5...
- webXL 8y agoThe popularity of transpilers might help overcome that barrier. IDE's and task runners can watch for file modifications and run a simple program to convert to the old format. But I'm curious what you mean by "in the wild"? If you're using (producing) it, something needs to consume it, and you would probably have control over both in whatever project you were using it for.
- emodendroket 8y agoIf you're going to do this kind of thing why would you not add a standard date format
- continuational 8y agoJust use a string and ISO 8601? “2018-03-25”
- wildrhythms 8y agoWhat's the timezone?
- lysium 8y agoDo you need a time zone for dates?
- wildrhythms 8y agoConsider if I'm storing a user's (local) birthday on my server: {..., "birthday": "2018-03-25"} If my server is located in New York City, and the user is in Sydney, then my server isn't going to wish them happy birthday in time. So maybe we could do: {..., "birthday": "2018-03-25", "location": "Sydney/AU"} But at this point we might as well use a standardized time format (UTC) with a timezone offset. Maybe I'm thinking too far into it?
- webXL 8y agoISO 8601 has you covered: Year: YYYY (eg 1997) Year and month: YYYY-MM (eg 1997-07) Complete date: YYYY-MM-DD (eg 1997-07-16) Complete date plus hours and minutes: YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00) Complete date plus hours, minutes and seconds: YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00) Complete date plus hours, minutes, seconds and a decimal fraction of a second YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00) where: YYYY = four-digit year MM = two-digit month (01=January, etc.) DD = two-digit day of month (01 through 31) hh = two digits of hour (00 through 23) (am/pm NOT allowed) mm = two digits of minute (00 through 59) ss = two digits of second (00 through 59) s = one or more digits representing a decimal fraction of a second TZD = time zone designator (Z or +hh:mm or -hh:mm)
- crooked-v 8y agoThe lack of template string support is a weird part of that.