def json_generator(items, root, expand=False):
 (yield ('{"%s":[' % root))
 first = True
 for item in items:
  if first:
   first = False
  else:
   (yield ',')
  (yield json.dumps(_rep(item, expand=expand)))
 (yield ']}')

def json_generator ( items , root , expand = False ) : ( yield ( '{"%s":[' % root ) ) first = True for item in items : if first : first = False else : ( yield ',' ) ( yield json . dumps ( _rep ( item , expand = expand ) ) ) ( yield ']}' )
generator that dumps list of beets items or albums as json .