input: Write a function to parse a json-formatted string into a dictionary. If the input is a valid json string, return the parsed dict, otherwise return None. 
  
  assert parse_json('{"name": "John", "age": 30, "address": {"city": "New York", "state": "NY"}}') == {"name": "John", "age": 30, "address": {"city": "New York", "state": "NY"}}
  assert parse_json('{"name": "Jane", "age": 25}') == {"name": "Jane", "age": 25}
  assert parse_json('invalid json string') == None
  assert parse_json('{"key": "value"') == None
  assert parse_json('') == None
output: def parse_json(json_str):
      try:
          return json.loads(json_str)
      except json.JSONDecodeError:
          return None