Skip to content

Commit

Permalink
json_dumps options
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Jun 28, 2024
1 parent e367bc6 commit 366c2c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions additionals/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def json_query(ctx, v, query):

@as_filter
@pass_context
def json_dumps(ctx, v):
return json.dumps(v)
def json_dumps(ctx, v, *, ensure_ascii=False, indent=None, sort_keys=False):
return json.dumps(v, ensure_ascii=ensure_ascii, indent=indent, sort_keys=sort_keys)


@as_filter
Expand Down
2 changes: 1 addition & 1 deletion testdata/default-example.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{%- for url in (github | json_query('[*.url,*.*.url,*.*.*.url] | [] | [] | []')) %}
* {{ url }}
{%- endfor %}
{{ 'test\n' | json_dumps }}
{{ '日本語test\n' | json_dumps(ensure_ascii=True) }}
{{ (github.event | json_dumps | json_loads).repository.name }}

{{ github | to_nice_yaml }}

0 comments on commit 366c2c0

Please sign in to comment.