Usually "Invalid get index" means that you've incorrectly called something - either because there's a slight misspelling or because the object you're calling does not exist.
"on base Nil" indicates that it can't find 'data' - can you confirm that everything in this line of code
var data = parse_json(file.get_line())
is properly entered, and consistent from previous usages?
You can try calling
print(data, count, file.get_line())
or
print("data is ", data, "count is ", count, "file.get_line() is ", file.get_line())
instead of the line of code "count = data.count"
, and then checking the console - what's coming up for data
? what's coming up for count
? file.get_line()
? that might help you see where the problem might be.