Best practices

In this section, we outline best practices for effectively using json.Serializer to enhance performance and avoid common pitfalls.

The following best practices can help ensure effective use of json.Serializer:

  • Disable allowImplicitConversion in production to avoid silent errors.
  • Use native JSON booleans and numbers rather than quoted values (for example, use true instead of "true").
  • Favor strict formats for DATE (YYYY-MM-DD) and DATETIME (YYYY-MM-DD HH:MM:SS).
  • Use json_null="null" when handling NULL values. For more information about managing null with the json_null attribute, go to NULLs and empty structures.