Use JSON files as if they are python modules

kragniz kragniz Last update: Mar 25, 2024

json-sempai

image

image

Have you ever been kept awake at night, desperately feeling a burning desire to do nothing else but directly import JSON files as if they were python modules 1? Now you can!

This abomination allows you to write

and if some_json_file.json can be found, it will be available as if it is a python module.

Usage

Slap a json file somewhere on your python path. tester.json:

Now import jsonsempai and your json file!

Alternatively, a context manager may be used (100% less magic):

Python packages are also supported:

Installing

Install from pip:

or clone this repo and install from source:

To purge this horror from your machine:


  1. Disclaimer: Only do this if you hate yourself and the rest of the world.

Subscribe to our newsletter