Macro to load json from file

The fromjson macro expects the input to be a json string.

Are there any macros to load json from a file?
If there are none, can you help me with pointers on how to write custom macros that do file io?

Thanks.

@venkatm dbt is designed to work with data that’s already in your database, and doesn’t have the ability to do file IO outside of what your warehouse exposes. What sort of JSON files are you trying to work with?

Thanks for getting back to me. I was trying to see if I could dynamically construct the SQL query using attributes read from a json file at runtime, without having to modify the dbt model file.

Depending on the number of attributes you need to manage, you might be able to use vars and the fact that you can pass those into a dbt invocation: Project variables | dbt Developer Hub

Can you post an example of the sort of query you want to generate, and which parts of it would vary based on the attributes? It’s hard to be much help in a hypothetical scenario