diff --git a/additionals/json.py b/additionals/json.py index a0e0d70..66c5185 100644 --- a/additionals/json.py +++ b/additionals/json.py @@ -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 diff --git a/testdata/default-example.j2 b/testdata/default-example.j2 index 7792b79..aa43c27 100644 --- a/testdata/default-example.j2 +++ b/testdata/default-example.j2 @@ -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 }}