#NEWLINE# def dump_as_json( results , valid = False ) : #NEWLINE# #INDENT# first = True #NEWLINE# if first : #NEWLINE# #INDENT# ( yield '[' ) #NEWLINE# #UNINDENT# for result in results : #NEWLINE# #INDENT# if valid : #NEWLINE# #INDENT# if first : #NEWLINE# #INDENT# first = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield ', ' ) #NEWLINE# #UNINDENT# #UNINDENT# ( yield ( json . dumps ( result , ensure_ascii = False ) + '\n' ) ) #NEWLINE# #UNINDENT# if valid : #NEWLINE# #INDENT# ( yield ']' )