Skip to content
Myr

Make the JSON module work better in the absence of an application context

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 77d293c · Browse files · 1 file+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−1 removed

  • other:+5 added−1 removed

1 file+5 added−1 removed

modified:flask/json.py+5 added-1 removed
90 unmodified lines
919293def _dump_arg_defaults(kwargs):94 """Inject default arguments for dump functions."""95 kwargs.setdefault('sort_keys', True)95 if current_app:96 kwargs.setdefault('cls', current_app.json_encoder)97 if not current_app.config['JSON_AS_ASCII']:98 kwargs.setdefault('ensure_ascii', False)99 kwargs.setdefault('sort_keys', current_app.config['JSON_SORT_KEYS'])100 else:101 kwargs.setdefault('sort_keys', True)102 kwargs.setdefault('cls', JSONEncoder)103104105def _load_arg_defaults(kwargs):106 """Inject default arguments for load functions."""107 if current_app:108 kwargs.setdefault('cls', current_app.json_decoder)109 else:110 kwargs.setdefault('cls', JSONDecoder)111112113def dumps(obj, **kwargs):114 """Serialize ``obj`` to a JSON formatted ``str`` by using the application's
101 unmodified lines