input: Write a function that creates a Flask API to fetch data from an SQL database and return the data in JSON format. The function should connect to the 'database.db', fetch all records from the 'users' table, and return them as a JSON response. The API should be accessible via a GET request to the root URL '/'.
  
  def create_sql_to_json_api():
      import json 
      import sqlite3
      from flask import Flask, request, jsonify 
  
      app = Flask(__name__) 
        
      def dict_factory(cursor, row):
          d = {}
          for idx, col in enumerate(cursor.description):
              d[col[0]] = row[idx]
          return d 
        
      @app.route('/', methods=['GET'])
      def index(): 
          connection = sqlite3.connect('database.db')
          connection.row_factory = dict_factory
          cur = connection.cursor() 
          all_users = cur.execute('SELECT * FROM users;').fetchall() 
          return jsonify(all_users) 
        
      if __name__ == '__main__': 
          app.run(debug = True)
      return app
  
  assert create_sql_to_json_api().test_client().get('/').status_code==200
  assert isinstance(json.loads(create_sql_to_json_api().test_client().get('/').data.decode()), list)
output: def create_sql_to_json_api():
      import json 
      import sqlite3
      from flask import Flask, request, jsonify 
  
      app = Flask(__name__) 
        
      def dict_factory(cursor, row):
          d = {}
          for idx, col in enumerate(cursor.description):
              d[col[0]] = row[idx]
          return d 
        
      @app.route('/', methods=['GET'])
      def index(): 
          connection = sqlite3.connect('database.db')
          connection.row_factory = dict_factory
          cur = connection.cursor() 
          all_users = cur.execute('SELECT * FROM users;').fetchall() 
          return jsonify(all_users) 
        
      if __name__ == '__main__': 
          app.run(debug = True)
      return app