def _write_dict(self, val, outstream):
fields = val.keys()<EOL>length = len(fields)<EOL>self.write_dict_start(length, outstream)<EOL>if length > <NUM_LIT:0>:<EOL><INDENT>self.write_dict_field(fields[<NUM_LIT:0>], val[fields[<NUM_LIT:0>]], outstream)<EOL>idx = <NUM_LIT:1><EOL>while idx < length:<EOL><INDENT>name = fields[idx]<EOL>value = val[fields[idx]]<EOL>self.write_dict_field_separator(name, value, outstream)<EOL>self.write_dict_field(name, value, outstream)<EOL>idx += <NUM_LIT:1><EOL><DEDENT><DEDENT>self.write_dict_end(length, outstream)<EOL>
write a dictionary
:param val:
:param outstream: