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