How does {{ timeout|default(0)|json }} work?

How does {{ timeout|default(0)|json }} work?

// bokeh/bokeh/core/_templates/autoload_nb_js.js:134,135

if (typeof (root._bokeh_timeout) === "undefined" || force === true) {
    root._bokeh_timeout = Date.now() + {{ timeout|default(0)|json }};

My guess was that the default(0) sets the default for variable timeout to 0 and the json converts it to string '0'. Not sure why you would do that.
I couldn’t find any default() (in this syntax) and json filter in django template builtins.

You couldn’t find the filters because Bokeh doesn’t use Django, it uses Jinja templates.
The default filter: https://jinja.palletsprojects.com/en/2.11.x/templates/#default
And the json filter: https://github.com/bokeh/bokeh/blob/master/bokeh/core/templates.py#L87

For why there is the json filter, I am not sure. It doesn’t change the value into a string because the template system handles it. It seems that it’s there just to make sure that we use only well-formed JSON values in JS files. Here’s the PR if you’re interested: https://github.com/bokeh/bokeh/pull/5603