til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Notes on JSON

I have seen a wide variety of JSON uses and many uses do not utilize JSON to the extent possible, meaning addition work has to be done to interpret the JSON.

These are my rules of thumb for setting up a JSON structure.

  • Use booleans, where this makes sense
  • Use numbers, for things that require calculation
  • Use strings for everything else

Booleans

Numbers

The case for using numbers over strings, is often that I see what should be numbers are represented as strings.

Strings

This rule of thumb is sort of the opposite of the two rules above. Use strings.

Resources and References

  • https://json-schema.org/understanding-json-schema/reference/string
  • https://github.com/bterlson/blog/blob/main/content/blog/what-is-a-json-number.md
  • https://blog.trl.sn/blog/what-is-a-json-number/