input: Write a function to parse a json-formatted string into a dictionary. Return the dictionary if the string is valid else return None. If the given string is empty then return an empty dictionary.
  assert parse_json_to_dict('{"name": "John","age": 30,"address": {"city": "New York","state": "NY"}}')=={'name': 'John', 'age': 30, 'address': {'city': 'New York', 'state': 'NY'}}
  assert parse_json_to_dict('{"name": "Jane","age": 25}')=={'name': 'Jane', 'age': 25}
  assert parse_json_to_dict('')=={}
  assert parse_json_to_dict('invalid json string')==None
output: def parse_json_to_dict(json_str):
      if not json_str:
          return {}
      try:
          return json.loads(json_str)
      except json.JSONDecodeError:
          return None