FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.92k stars 218 forks source link

Mixed types arrays in ankiconnect #412

Open uieoa opened 10 months ago

uieoa commented 10 months ago

First of all, thank you for a great work with this plugin

Some methods like getNumCardsReviewedByDay do return an array with various data types, like this:

{"result": [["2023-10-21", 10], ["2023-10-18", 45]], "error": null}

where "2023-10-21" is a string and 10 is int. I think it makes no problem for python or js but for swift and other strong-typed languages this behavior causes a lot of troubles.
Hacks are really dirty: https://stackoverflow.com/questions/48996643/parse-json-array-that-contains-string-and-int-in-swift-4

I would like to suggest two solutions:

  1. New methods like getNumCardsReviewedByDay_strong which will always return an array of array of strings like: {"result": [["2023-10-21", "10"], ["2023-10-18", " 45"]], "error": null}
  2. New methods like getNumCardsReviewedByDay_strong which will always return an array of some data like: {"result": [{"date": "2000-01-01T01:01:01", count: 10}, {"date": "2020-02-02T01:01:01", count: 45}], "error": null}

I think I can make a PR to any of this but which way do you like the best?

Kind regards