input: Write a function to create a feature extraction function in Python to extract data from a json string. The function should take a json string as input and return a dictionary containing the extracted features, including the "id", "title", and the length of the "body". If the input string is not a valid json, the function should return an empty dictionary.
  def feature_extraction(input_str):
      import json
      data = json.loads(input_str, strict=False)
  
      features = {
          "id": data["id"],
          "title": data["title"],
          "body_len": len(data["body"])
      }
  
      return features
  
  assert feature_extraction('{"id":111,"title":"This is a sample title","body":"This is a sample body text"}')=={"id": 111, "title": "This is a sample title", "body_len": 30}
  assert feature_extraction('{"id":222,"title":"Another sample","body":"Short text"}')=={"id": 222, "title": "Another sample", "body_len": 10}
  assert feature_extraction('{"invalid":111,"not_title":"Oops","err":""}')=={}
output: def feature_extraction(input_str):
      try:
          import json
          data = json.loads(input_str)
          return {
              "id": data["id"],
              "title": data["title"],
              "body_len": len(data["body"])
          }
      except (json.JSONDecodeError, KeyError):
          return {}