<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_json(data, filename):
 """Custom handler for writing json file in InaSAFE. Criteria: - use indent = 2 - Handle NULL from QGIS :param data: The data that will be written. :type data: dict :param filename: The file name. :type filename: str """


    def custom_default(obj):
        if obj is None or (hasattr(obj, 'isNull') and obj.isNull()):
            return ''
        raise TypeError

    with open(filename, 'w') as json_file:
        json.dump(data, json_file, indent=2, default=custom_default)