mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
?_json_infinity=1 for handling Infinity/-Infinity - fixes #332
This commit is contained in:
parent
b320f58d13
commit
700d83d8ad
5 changed files with 64 additions and 2 deletions
|
|
@ -20,8 +20,10 @@ from datasette.utils import (
|
|||
path_from_row_pks,
|
||||
path_with_added_args,
|
||||
path_with_format,
|
||||
remove_infinites,
|
||||
resolve_table_and_format,
|
||||
to_css_class
|
||||
to_css_class,
|
||||
value_as_boolean,
|
||||
)
|
||||
|
||||
ureg = pint.UnitRegistry()
|
||||
|
|
@ -334,6 +336,12 @@ class BaseView(RenderMixin):
|
|||
data["rows"], data["columns"], json_cols,
|
||||
)
|
||||
|
||||
# unless _json_infinity=1 requested, replace infinity with None
|
||||
if "rows" in data and not value_as_boolean(
|
||||
request.args.get("_json_infinity", "0")
|
||||
):
|
||||
data["rows"] = [remove_infinites(row) for row in data["rows"]]
|
||||
|
||||
# Deal with the _shape option
|
||||
shape = request.args.get("_shape", "arrays")
|
||||
if shape == "arrayfirst":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue