# Source # Mastering Object-Oriented Python - Second Edition by Steven F. Lott Published by Packt Publishing, 2019 # https://learning.oreilly.com/library/view/mastering-object-oriented-python/9781789531367/c34be237-5ccd-4775-a0b0-ec1f7652f7bc.xhtml # from pathlib import Path # write JSON files: with Path("temp.json").open("w", encoding="UTF-8") as target: json.dump(travel3, target, default=blog_j2_encode) # read JSON files: from pathlib import Path with Path("some_source.json").open(encoding="UTF-8") as source: objects = json.load(source, object_hook=blog_decode)