Skip to content

Commit c4876f9

Browse files
authored
Merge pull request #38 from srz-zumix/feature/json_dumps_option
json_dumps options
2 parents e367bc6 + 366c2c0 commit c4876f9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

additionals/json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def json_query(ctx, v, query):
1414

1515
@as_filter
1616
@pass_context
17-
def json_dumps(ctx, v):
18-
return json.dumps(v)
17+
def json_dumps(ctx, v, *, ensure_ascii=False, indent=None, sort_keys=False):
18+
return json.dumps(v, ensure_ascii=ensure_ascii, indent=indent, sort_keys=sort_keys)
1919

2020

2121
@as_filter

testdata/default-example.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{%- for url in (github | json_query('[*.url,*.*.url,*.*.*.url] | [] | [] | []')) %}
1515
* {{ url }}
1616
{%- endfor %}
17-
{{ 'test\n' | json_dumps }}
17+
{{ '日本語test\n' | json_dumps(ensure_ascii=True) }}
1818
{{ (github.event | json_dumps | json_loads).repository.name }}
1919

2020
{{ github | to_nice_yaml }}

0 commit comments

Comments
 (0)