Use number types instead of stringifying everything

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the data category.

Last Updated: 2021-05-15

In Semicolon&Sons, I started off with the following JSON data, using strings for everything, including numbers

  "id": "4",
  "name": "Vim the (Almost) IDE",
  "number": "2",
  "access": "public",
  "youtube_id": "ABC",
  "description": "A whirlwind tour of file navigation, autocomplete, LSP, running tests, git integration and more in Vim.",
  "published_on": "2020-04-17",
  "series_id": "2"

But later I came to regret this, because validations (e.g. with json schema) were difficult to carry out on the numerical strings (instead of purely numerical types), requiring regexes instead of simple type checks.


Where numerical types exist, use them instead of shoe-horning everything into strings.