input: Write a function to parse a json-formatted string into a dictionary. If the input string is not a valid json, the function should return an empty dictionary.
  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": "John", "age": 30, "address": {"city": "New York", "state": "NY"}}')=={"name": "John", "age": 30, "address": {"city": "New York", "state": "NY"}}
  assert parse_json('invalid json string')=={}
  assert parse_json('')=={}
  assert parse_json(None)=={}
output: try:
      import json
      return json.loads(s) if s else {}
  except (json.JSONDecodeError, TypeError):
      return {}