Skip to content

Comment on Designing a REST API: Unix Time vs. ISO-8601 (2013)parent

Comments

Semantically timestamp is a product type imho, so the logical representation in JSON would be with an object: {"year" 2022, "month": 4, "day": 1, ...etc}. The fact that nobody does that and instead serialize it to ISO-style string is telling about json.

The fact that nobody does that and instead serialize it to ISO-style string is telling about json.

Tell me more about that. I'm not sure I grasp what it is telling about JSON?

I see it as a sign that JSON is not that great for structured data if people prefer to pack their datetime structure into a string rather than the more native object format.

Oh, gotcha. Well, I definitely agree it would make more sense for it to be an object like you mentioned but I think it's probably more explainable by the fact there is native support for ISO date / time strings in most programming languages, making it just as easy to parse a date or time from a string value and having the added advantage of reducing the size of the payload on the wire. I could be wrong

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.