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

Better handling of typed values in JSON #354

Open
jakirkham opened this issue Dec 4, 2018 · 2 comments
Open

Better handling of typed values in JSON #354

jakirkham opened this issue Dec 4, 2018 · 2 comments
Labels
enhancement New features or improvements

Comments

@jakirkham
Copy link
Member

There has been a fair bit of discussion in issues ( #216 ), ( #156 ), and ( #244 ) about trying to store data that does not strictly have a JSON equivalent. There's a pretty good listing of interesting types in this comment specifically. Wanted to try to address this discussion at a higher level than specific failure modes observed.

Namely how do want to represent this non-JSON serializable data. Some suggestions are listed below. Others are certainly welcome.

  1. Base64 encode the binary data and label it as such ( Object array fill value #216 (comment) ) ( Complex dtype error  #244 (comment) )
  2. Dump the data into strings with a label indicating extraction type
  3. Store the metadata in Arrays and link them
  4. Allow the use of codecs on these values (e.g. users specify how to make it JSON friendly)
  5. Learn from and/or use other OSS libraries in this space (e.g. jsonpickle, json-tricks, etc.)

Thoughts?


Side Note: Raised issue ( numpy/numpy#12481 ) with NumPy to ask for a (blessed) way to export/import NumPy arrays to/from JSON as that seems to be at the core of this issue. It may not be solved before we address this issue ourselves, but hopefully getting involved in that discussion early will shape what we end up with and make it easier to migrate to anything NumPy may offer in the future.

@alimanfoo
Copy link
Member

Thanks @jakirkham. FWIW it might be worth breaking down all the different use cases as it may be that different solutions are required. Here's the ones I'm aware of:

@jakirkham
Copy link
Member Author

Thanks @alimanfoo.

IIUC issue ( #156 ) was discussing storing NumPy scalars as attributes as opposed to dtype objects themselves. Is that your understanding as well or did I miss something?

As to the other use cases, they seem to always have been about storing NumPy values in JSON of various types. Whether these be NumPy scalars or perhaps NumPy arrays. Also whether they were in fill values or attributes. So that's probably the best set of cases for us to address first.

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

No branches or pull requests

3 participants