Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid JSON in .zattrs file #75

Open
meggart opened this issue Feb 27, 2019 · 1 comment
Open

Invalid JSON in .zattrs file #75

meggart opened this issue Feb 27, 2019 · 1 comment

Comments

@meggart
Copy link
Contributor

meggart commented Feb 27, 2019

I have problems reading the new datacubes from the Julia API, because the attributes contain some invalid JSON, for example:

jovyan@ffd431271abc:~/.julia/packages/CMake/ZGawK/deps/downloads$ cat /home/jovyan/work/datacube/ESDCv2.0.0/esdc-8d-0.25deg-184x90x90-2.0.0.zarr/Rg/.zattrs
{
    "ID": 2,
    "_ARRAY_DIMENSIONS": [
        "time",
        "lat",
        "lon"
    ],
    "esa_cci_path": NaN,
    "long_name": "Downwelling shortwave radiation",
    "orig_version": "15.10.2017",
    "project_name": "BESS",
    "time_coverage_end": "2010-12-31",
    "time_coverage_resolution": "P8D",
    "time_coverage_start": "2000-03-01",
    "url": "http://environment.snu.ac.kr/bess_rad/"

This contains the entry NaN which should be converted to null 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 either None, which should be converted to null when encoding to JSON or to empty strings?

@meggart
Copy link
Contributor Author

meggart commented Feb 27, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant