To enable type coversions for a user defined struct, we need to define from_json and to_json in the same namespace as the struct. Then, using Argument Dependent Lookup (ADL), the functions are found and conversion happens.

For third-party types, since we can’t add new functions to their namespaces we can use a different method. It involves specialising the adl_serializer class in the nlohmann namespace.