Is it better to set the default MYSQL JSON value to `{}` or `NULL`

Random5000 picture Random5000 · Mar 15, 2018 · Viewed 8k times · Source

We are starting to use the MySQL json datatype. Is there any recommended best practices when storing default values as NULL or {} for the JSON datatype? What are the PROs and CONs for each?

Answer

rkudva picture rkudva · Apr 27, 2018

This would depend upon your business use-case.

  • null is usually meant to indicate that the value is unknown/doesn't exists.
  • {} on the other hand means that the value is known/does exist and the known value is an empty JSON object {}