def sanitize_for_serialization(self, obj):
types = (str, int, float, bool, tuple)<EOL>if sys.version_info < (<NUM_LIT:3>,<NUM_LIT:0>):<EOL><INDENT>types = types + (unicode,)<EOL><DEDENT>if isinstance(obj, type(None)):<EOL><INDENT>return None<EOL><DEDENT>elif isinstance(obj, types):<EOL><INDENT>return obj<EOL><DEDENT>elif isinstance(obj, list):<EOL><INDENT>return [self.sanitize_for_serialization(sub_obj)<EOL>for sub_obj in obj]<EOL><DEDENT>elif isinstance(obj, (datetime, date)):<EOL><INDENT>return obj.isoformat()<EOL><DEDENT>else:<EOL><INDENT>if isinstance(obj, dict):<EOL><INDENT>obj_dict = obj<EOL><DEDENT>else:<EOL><INDENT>obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)<EOL>for attr, _ in iteritems(obj.swagger_types)<EOL>if getattr(obj, attr) is not None}<EOL><DEDENT>return {key: self.sanitize_for_serialization(val)<EOL>for key, val in iteritems(obj_dict)}<EOL><DEDENT>
Builds a JSON POST object.

If obj is None, return None.
If obj is str, int, float, bool, return directly.
If obj is datetime.datetime, datetime.date
    convert to string in iso8601 format.
If obj is list, sanitize each element in the list.
If obj is dict, return the dict.
If obj is swagger model, return the properties dict.

:param obj: The data to serialize.
:return: The serialized form of data.