def _write_object(self, val, outstream):
<EOL>serializer = self.__lookup_serializer(getattr(val, '<STR_LIT>'))<EOL>if serializer is not None:<EOL><INDENT>serializer.serialize(self, val, outstream)<EOL>return<EOL><DEDENT>fields = self._fetch_obj_fields(val)<EOL>validfields = [];<EOL>encodedfields = []<EOL>length = <NUM_LIT:0>;<EOL>for f in fields:<EOL><INDENT>encoded = self._encode_field_name(val, f)<EOL>if encoded:<EOL><INDENT>encodedfields.append(encoded)<EOL>validfields.append(f)<EOL>length += <NUM_LIT:1>;<EOL><DEDENT><DEDENT>self.write_object_start(length, outstream)<EOL>count = <NUM_LIT:0>;<EOL>if length > <NUM_LIT:0>:<EOL><INDENT>mappedname = encodedfields[<NUM_LIT:0>]<EOL>if mappedname is not None:<EOL><INDENT>count += <NUM_LIT:1><EOL>self.write_object_field(mappedname, getattr(val, validfields[<NUM_LIT:0>]), outstream)<EOL><DEDENT>idx = <NUM_LIT:1><EOL>while idx < length:      <EOL><INDENT>name = validfields[idx]<EOL>mappedname = encodedfields[idx]<EOL>if mappedname is not None:<EOL><INDENT>value = getattr(val, name)<EOL>if count > <NUM_LIT:0>:<EOL><INDENT>self.write_object_field_separator(mappedname, value, outstream)<EOL><DEDENT>self.write_object_field(mappedname, value, outstream)<EOL>count += <NUM_LIT:1><EOL><DEDENT>idx += <NUM_LIT:1><EOL><DEDENT><DEDENT>self.write_object_end(length, outstream)<EOL>
Write object into the stream
:param val:
:param outstream: