This PR adds an optional argument to the |tojson filter, which controls if the serialized JSON data gets prettified or not. The arguments works the same as flask's |tojson filter, which passes the argument to python's json.dumps():
Omitting the argument, providing a negative integer, or None, then compact JSON data is generated.
Providing a non-negative integer, then this amount of ASCII spaces is used to indent the data. (Capped to 16 characters.)
Providing a string, then this string is used as prefix. I attempts are made to ensure that the prefix actually consists of whitespaces, because chances are, that if you provide e.g. &nsbp;, then you are doing it intentionally.
This is a breaking change, because it changes the default behavior to not prettify the data. This is done intentionally, because this is how it works in flask.
This PR adds an optional argument to the
|tojson
filter, which controls if the serialized JSON data gets prettified or not. The arguments works the same as flask's|tojson
filter, which passes the argument to python'sjson.dumps()
:None
, then compact JSON data is generated.&nsbp;
, then you are doing it intentionally.This is a breaking change, because it changes the default behavior to not prettify the data. This is done intentionally, because this is how it works in flask.