def safe_to_json(in_obj):
if isinstance(in_obj, bytearray):<EOL><INDENT>return str(in_obj)<EOL><DEDENT>if hasattr(in_obj, '<STR_LIT>'):<EOL><INDENT>return in_obj.__dict__<EOL><DEDENT>try:<EOL><INDENT>return str(in_obj)<EOL><DEDENT>except:<EOL><INDENT>return repr(in_obj)<EOL><DEDENT>
Safely get dict from object if present for json dumping