diff --git a/src/aerovaldb/jsondb/jsonfiledb.py b/src/aerovaldb/jsondb/jsonfiledb.py index fdb290d..d97d52d 100644 --- a/src/aerovaldb/jsondb/jsonfiledb.py +++ b/src/aerovaldb/jsondb/jsonfiledb.py @@ -37,8 +37,10 @@ def json_dumps_wrapper(obj, **kwargs) -> str: """ Wrapper which calls simplejson.dumps with the correct options, known to work for objects returned by Pyaerocom. + + This ensures that nan values are serialized as null to be compliant with the json standard. """ - return simplejson.dumps(obj, allow_nan=True, **kwargs) + return simplejson.dumps(obj, ignore_nan=True, **kwargs) class AerovalJsonFileDB(AerovalDB): diff --git a/tests/jsondb/test_jsonfiledb.py b/tests/jsondb/test_jsonfiledb.py index 46df488..1e2b12b 100644 --- a/tests/jsondb/test_jsonfiledb.py +++ b/tests/jsondb/test_jsonfiledb.py @@ -356,7 +356,7 @@ def test_write_and_read_of_nan(tmp_path): read = db.get_by_uri("./test") - assert math.isnan(read["value"]) + assert read["value"] is None def test_exception_on_unexpected_args():