Error while loading virtual doctype list View

While loading the list view of the virtual doctype,error occurs as Values are not getting Fetched . I had followed what is mentioned in the virtual doctype Frappe documentation
image

import frappe
from frappe.model.document import Document

import os
import json

class TestVirtual(Document):

DATA_FILE = "test_virtual.json"
@staticmethod
def get_current_data() -> dict[str, dict]:
	if not os.path.exists(TestVirtual.DATA_FILE):
		return {}

	with open(TestVirtual.DATA_FILE) as f:
		return json.load(f)

@staticmethod
def update_data(data: dict[str, dict]) -> None:
	with open(TestVirtual.DATA_FILE, "w+") as test_virtual:
		json.dump(data, test_virtual)

def db_insert(self):
	d = self.get_valid_dict(convert_dates_to_str=True)
	data = self.get_current_data()
	data[d.name] = d

def load_from_db(self):
	data = self.get_current_data()
	d = data.get(self.name)
	super(Document, self).__init__(d)

def db_update(self,*args, **kwargs):
	self.db_insert(*args, **kwargs)

def delete(self):
	data = self.get_current_data()
	data.pop(self.name, None)
	self.update_data(data)

@staticmethod
def get_list(self, args):
	data = TestVirtual.get_current_data()
	return [frappe._dict(doc) for name, doc in data.items()]


@staticmethod
def get_count(self, args):
	data = TestVirtual.get_current_data()
	return len(data)

@staticmethod
def get_stats(self, args):
	return {}

Hi:

Check where your json file is located … base directory is “your-bench/sites”
Hope this helps.