def extract_fields(json):
  """Extracts a JSON dict of fields.
  
  REST and RPC protocols use different JSON keys for OpenSocial objects. This
  abstracts that and handles both cases.
  
  Args:
    json: dict The JSON object.
  
  Returns: A JSON dict of field/value pairs.

  """
  return json.get('entry') or json