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

Dataset JSON GET API returns numbers as strings #9494

Open
vera opened this issue Apr 5, 2023 · 3 comments
Open

Dataset JSON GET API returns numbers as strings #9494

vera opened this issue Apr 5, 2023 · 3 comments
Labels

Comments

@vera
Copy link
Contributor

vera commented Apr 5, 2023

What steps does it take to reproduce the issue?

  1. Enable metadata block with fields with fieldType int or float
  2. Create dataset
  3. Use the JSON GET API to retrieve the dataset https://guides.dataverse.org/en/latest/api/native-api.html#get-json-representation-of-a-dataset e.g. GET /api/datasets/42?exporter=dataverse_json
  • What happens?

The values for the numerical fields are returned as strings, e.g. {'typeName': 'my_int_field', 'multiple': False, 'typeClass': 'primitive', 'value': '5'}

  • What did you expect to happen?

The numerical fields to be returned as integers/floats, e.g. {'typeName': 'my_int_field', 'multiple': False, 'typeClass': 'primitive', 'value': 5}

Which version of Dataverse are you using?

v5.13

Any related open or closed issues to this bug report?

/

Screenshots:

/

@vera
Copy link
Contributor Author

vera commented Apr 5, 2023

I would be happy to submit a PR (I assume this would not be very hard to fix?!) if someone could point me to the right part of the code.

@qqmyers
Copy link
Member

qqmyers commented Apr 5, 2023

FWIW: This wouldn't be hard to change (I think the code is all in util.JsonPrinter) but there would be many places where that format is used that would have to change - most of the metadata exporters parse that JSON, previewers and external tools use it, probably pyDataverse, community-developed applications, and we expect to be able to read that format back in, so all of the code to import the Json could have to be changed to accept this (hopefully keeping backward compatibility as well). I know some JSON APIs will work as long as the value can be converted to the requested type, but I think there are a lot of places where a change like this could have an effect.

There is some discussion going on w.r.t. using a JSON Schema (e.g. in #9463) which could involve changes to the JSON output that would be significant enough to perhaps be a version 2 of the API and where changes like this might be something to incorporate.

@pdurbin
Copy link
Member

pdurbin commented Apr 5, 2023

To ensure backward compatibility and to prevent breaking all that third party code, we could add additional fields to the JSON response.

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

No branches or pull requests

3 participants