Switch to a library which is more well-known. I also thought the library was the problem for not being able to template in a JSON path, but that is just a PostgreSQL problem it seems.
Refactor the code to get rid of global variables. Also improve the docs.