code: def save_json(filename: str, config: Union[List, Dict]):
      
      try:
          data = json.dumps(config, sort_keys=True, indent=4)
          with open(filename, 'w', encoding='utf-8') as fdesc:
              fdesc.write(data)
              return True
      except TypeError as error:
          _LOGGER.exception('Failed to serialize to JSON: %s',
                            filename)
          raise PytradfriError(error)
      except OSError as error:
          _LOGGER.exception('Saving JSON file failed: %s',
                            filename)
          raise PytradfriError(error)
docs: Save JSON data to a file.
  
      Returns True on success.