3 ms·
I feel like the comments are the only important part. I’d rather not have single quoted strings or unquoted identifiers to be honest. Trailing commas are nice t
by eknkc 2y ago
I feel like the comments are the only important part. I’d rather not have single quoted strings or unquoted identifiers to be honest. Trailing commas are nice to have though.
All I miss in JSON are comments and a native datetime type. Everything else, I’m fine with.
- BurningFrog 2y agoFor comments, adding "_comment": "..." fields can work pretty well.
- viraptor 2y agoNot where the reader verifies the schema. And not when you want to write a long multiline comment. (Unless you want _comment1, _comment2, ...)
- btown 2y agoAn array of strings works well here! Also, you can always preprocess to remove comments before validating!
- oneeyedpigeon 2y agoIf you're preprocessing, you might as well just `grep -v ^#` and support 'real' comments.
- btown 2y agoThere's power to it being valid JSON, though; it can be stored in databases optimized for JSON payloads, and edited with JSON editors. There's a real agility to liberally sprinkling JSONFields and JSON code editors across an auto-generated admin interface like the Django admin system, knowing that you can leave breadcrumbs for colleagues, and that anything starting with a `__` is fair game for comments any time you see such a key name.
- sevensor 2y agoStrongly disagree about datetimes; they exist at a different semantic level and are entirely too easy to get wrong.
- wruza 2y agoNot more than a string representing a date that gets interpreted after json.parse.
- int_19h 2y agoLuckily, we have decades of experience in e.g. SQL, and existing and well-polished ISO specs on dates that can just be used as is without reinventing the wheel.
- Sohcahtoa82 2y agoYeah, but OmegaStar still doesn't support ISO timestamps like they said they would a month ago! (Reference: https://youtu.be/y8OnoxKotPQ https://youtu.be/y8OnoxKotPQ)
- Aloisius 2y agoAs if anyone actually implements ISO 8901 correctly. JavaScript certainly doesn't.
- int_19h 2y agoJS at least implements a strict subset of it for UTC, which is still a useful starting point.
- eknkc 2y agoI mean, floating point numbers are easy to get wrong. And why care about semantics? This is a data transfer format, it should be able to represent data that is being transferred gazillion times a day. Make it raw ISO 8601 { "created_at": 2024-12-10T11:20:07Z } and do not accept any other format. I know there are way smarter people than me who can figure this out at this point. DateTimes are the number 1 reason I can not use JSON data as is (if I simply parse it into a dynamic object like JSON.parse).
- dariusj18 2y agoIMO it would be great if fields could have annotations for types that fall back as strings. Datetimes could be annotated for easier parsing.