code: def to_json(self, filename=None,
                  encoding="utf-8", errors="strict",
                  multiline=False, **json_kwargs):
          
          if filename and multiline:
              lines = [_to_json(item, filename=False, encoding=encoding,
                                errors=errors, **json_kwargs) for item in self]
              with open(filename, 'w', encoding=encoding, errors=errors) as f:
                  f.write("\n".join(lines).decode('utf-8') if
                          sys.version_info < (3, 0) else "\n".join(lines))
          else:
              return _to_json(self.to_list(), filename=filename,
                              encoding=encoding, errors=errors, **json_kwargs)
docs: Transform the BoxList object into a JSON string.
  
          :param filename: If provided will save to file
          :param encoding: File encoding
          :param errors: How to handle encoding errors
          :param multiline: Put each item in list onto it's own line
          :param json_kwargs: additional arguments to pass to json.dump(s)
          :return: string of JSON or return of `json.dump`