Open meggart opened 5 years ago
Here is the relevant section in the python module json.dump
documentation https://docs.python.org/3/library/json.html:
If allow_nan is false (default: True), then it will be a ValueError to serialize out of range float values (nan, inf, -inf) in strict compliance of the JSON specification. If allow_nan is true, their JavaScript equivalents (NaN, Infinity, -Infinity) will be used.
So they do not adhere to JSON specs by default.
I have problems reading the new datacubes from the Julia API, because the attributes contain some invalid JSON, for example:
This contains the entry
NaN
which should be converted tonull
according to JSON spec. I don't know if the error comes from the xarray, zarr or some other python package, but could we work around this issue by setting non-existing attributes in python to eitherNone
, which should be converted tonull
when encoding to JSON or to empty strings?