<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_json(objects, filename, warnings=True):
 """ Export the indicators of one or several users to JSON. Parameters objects : list List of objects to be exported. filename : string File to export to. Examples -------- This function can be use to export the results of :meth`bandicoot.utils.all`. If you only have one object, you can simply pass it as argument: """


    if not isinstance(objects, list):
        objects = [objects]

    obj_dict = OrderedDict([(obj['name'], obj) for obj in objects])

    with open(filename, 'w') as f:
        f.write(dumps(obj_dict, indent=4, separators=(',', ': ')))

    if warnings:
        print("Successfully exported {} object(s) to {}".format(len(objects),
              filename))