GothenburgBitFactory / holidata

Holidata is the core of holidata.net, a no-nonsense, ad-free provider of international holiday data.
https://holidata.net
MIT License
47 stars 13 forks source link

JsonEmitter returns invalid JSON object #66

Closed sliwkr closed 3 years ago

sliwkr commented 3 years ago

Describe the bug holidata --year=2020 --locale='de-DE' --output=json returns invalid JSON response. While each individual holiday object is correct, the response as a whole should be wrapped in square brackets, and objects separated by a comma.

Expected behavior Valid JSON array (as in https://www.json.org/json-en.html) of holiday objects is returned.

Additional context Fixing this should solve SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 2 column 1 of the JSON data when entering for example https://holidata.net/en-US/2016.json on firefox.

lauft commented 3 years ago

You are right, holidata's JSON output is not 100% valid JSON. However, the data format has its roots in the holiday files feature of Taskwarrior and Timewarrior which are the two main consumer of this output format. So a correction here has to go hand in hand with an adaption of the respective refresh script in each project and a migration period/strategy.

sliwkr commented 3 years ago

Hey, sorry for the delayed response. Haven't realized that this was intentional and read https://holidata.net/formats/json/ just recently. Will take a look on how it's implemented in both Taskwarrior and Timewarrior and either bail out or send PR's respectively

lauft commented 3 years ago

The documentaion on holidata.net has been updated to clarify that the data in the "JSON format" is stored as a newline-delimited JSON (https://jsonlines.org). This decision was made on purpose and changing it to "standard JSON" would require to adapt every consumer (foremost Timewarrior and Taskwarrior, but there may be more) to this change. Regarding that the JSON Lines text file format is simple and easy to use, IMHO the effort to change the data to standard JSON is not worth the benefits.

Therefore (and also due to inactivity) I am closing this.