Expressing time duration metrics in JSON-stat

11 views
Skip to first unread message

Xavier Badosa

unread,
Sep 19, 2021, 1:44:38 PM9/19/21
to json-stat

I noticed that Eurostat has tables with values expressed as "hh:mm". For example:

https://ec.europa.eu/eurostat/databrowser/view/tus_00alone/default/table?lang=en

Eurostat's JSON-stat API, though, doesn't seem to be able to return data when it comes to counting hours:

https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tus_00alone?unit=PTP_TIME&precision=1

In the response to the previous request, the "value" property is empty. But, of course, there is no reason for this: it is possible to disseminate cells with time duration information in the JSON-stat format.

"hh:mm" is a way of formatting data (presentation) but it's not an allowed way of storing a number in JSON. The JSON-stat spec, though, never says that the content of a cell should be a number (technically "10:30" is a valid JSON-stat cell value). So the first approach is using strings to return time duration values in the JSON-stat format.

Of course, when possible, cell data should be exposed as numbers (separation of content and presentation). Time duration cells can be expressed as regular numbers (transforming "10:30" into 10.5). This is a better approach than using strings because in the end it should be up to the data consumer to decide how to present such information (as hh:mm -10:30-, as hh.dd -10.50-, as percentual fraction of a day -43.75-...).

Xavier

Reply all
Reply to author
Forward
0 new messages