def _ModelToDictForJson(model_obj):
  """Return the data of an app engine model as a dict.

  Args:
    model_obj: a model object to be serialized

  Returns:
    an object suitable for simplejson.dumps'ing

  Note:
    this is generic, but if the object has unserializable
    properties this will not be so useful.
  """
  result = {}
  for key in model_obj.properties():
    value = getattr(model_obj, key)
    if hasattr(value, 'DictForJson'):
      value = value.DictForJson()
    result[key] = value
  return result