import json
import logging


def get_message_from_json(body):
  """Parses JSON from request body.

  Returns parsed JSON object if JSON is valid and the represented object is a
  dictionary, otherwise returns None.
  """
  try:
    message = json.loads(body)
    if isinstance(message, dict):
      return message
    logging.warning('Expected dictionary message'
        + ', request=' + body)
    return None
  except Exception as e:
    logging.warning('JSON load error from BindPage: error=' + str(e)
        + ', request=' + body)
    return None