I got "AttributeError: \'NoneType\' object has no attribute \'to_json\'" when I tried to make a function that would give output in JSON file using Jupyter notebook