input: Write a function called fetch_data_as_json that fetches data from an SQL database and returns it as a JSON object. The function should establish a connection to the database, execute a SELECT query to retrieve all records from the "users" table, and use a custom row factory to convert the results into a list of dictionaries. Finally, it should return the JSON-formatted data.
  
  def fetch_data_as_json():
      import json 
      import sqlite3
      connection = sqlite3.connect('database.db')
      connection.row_factory = dict_factory
      cur = connection.cursor() 
      all_users = cur.execute('SELECT * FROM users;').fetchall() 
      connection.close()
      return jsonify(all_users)
  
  assert fetch_data_as_json() == [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]
  assert fetch_data_as_json() == [{"id": 1, "name": "John"}, {"id": 2, "name": "Jane"}]
  assert fetch_data_as_json() == [{"id": 1, "name": "Eve"}, {"id": 2, "name": "Daniel"}]
  assert fetch_data_as_json() == []
  assert fetch_data_as_json() == [{"id": 1, "name": "Chris"}, {"id": 2, "name": "Mia"}]
output: def fetch_data_as_json():
      import json 
      import sqlite3
      def dict_factory(cursor, row):
          d = {}
          for idx, col in enumerate(cursor.description):
              d[col[0]] = row[idx]
          return d
      connection = sqlite3.connect('database.db')
      connection.row_factory = dict_factory
      cur = connection.cursor() 
      all_users = cur.execute('SELECT * FROM users;').fetchall() 
      connection.close()
      return json.dumps(all_users)