def json_encode(obj, serialize):
if hasattr(obj, '<STR_LIT>'):<EOL><INDENT>return obj.to_dict(serialize=serialize)<EOL><DEDENT>elif isinstance(obj, datetime):<EOL><INDENT>return obj.date().isoformat()<EOL><DEDENT>elif isinstance(obj, date):<EOL><INDENT>return obj.isoformat()<EOL><DEDENT>elif isinstance(obj, ProxyDict):<EOL><INDENT>return dict(obj)<EOL><DEDENT>elif isinstance(obj, ProxyList):<EOL><INDENT>return list(obj)<EOL><DEDENT>elif is_iterable_but_not_string(obj):<EOL><INDENT>return list(obj)<EOL><DEDENT>
Handle encoding complex types.