Is this your first time submitting a feature request?
Describe the feature
Add indent parameter to tojson and toyaml. These are straight mappings to the equivalent indent parameters in the respective json.dumps and yaml.safe_dump methods. Adding the indent parameter helps with debugging when developing with objects in Jinja.
Describe alternatives you've considered
No response
Who will this benefit?
This will help dbt macro developers to debug their processes.
Are you interested in contributing this feature?
Yes
Anything else?
This specifically came about because I wanted to make use of the sort_keys parameter, which is available in the tojson context method, but not the tojson Jinja filter:
{%- set myobj = {'a':{'ab':1},{'b':{'ba':2}}-%}
{# Not valid! #}
{{ myobj | tojson(sort_keys=False}}
{{ tojson(myobj,indent=2) }}
{# Valid #}
{{ tojson(myobj,sort_keys=False) }}
{{ myobj | tojson(indent=2}}
{# Valid after this change implemented #}
{{ tojson(myobj,sort_keys=False,indent=2) }}
Currently the last statement errors with:
Encountered an error: Error parsing inline query
Error while parsing node: inline_query BaseContext.tojson() got an unexpected keyword argument 'indent'
Is this your first time submitting a feature request?
Describe the feature
Add
indentparameter totojsonandtoyaml. These are straight mappings to the equivalent indent parameters in the respectivejson.dumpsandyaml.safe_dumpmethods. Adding the indent parameter helps with debugging when developing with objects in Jinja.Describe alternatives you've considered
No response
Who will this benefit?
This will help dbt macro developers to debug their processes.
Are you interested in contributing this feature?
Yes
Anything else?
This specifically came about because I wanted to make use of the
sort_keysparameter, which is available in the tojson context method, but not the tojson Jinja filter:{%- set myobj = {'a':{'ab':1},{'b':{'ba':2}}-%} {# Not valid! #} {{ myobj | tojson(sort_keys=False}} {{ tojson(myobj,indent=2) }} {# Valid #} {{ tojson(myobj,sort_keys=False) }} {{ myobj | tojson(indent=2}} {# Valid after this change implemented #} {{ tojson(myobj,sort_keys=False,indent=2) }}Currently the last statement errors with: