code: def items2file(items, filename, encoding='utf-8', modifier='w'):
      
      with codecs.open(filename, modifier, encoding=encoding) as f:
          for item in items:
              f.write(u"{}\n".format(json.dumps(
                  item, ensure_ascii=False, sort_keys=True)))
docs: json array to file, canonical json format