Doesn't support all primitive types #9

Closed
opened 6 years ago by novirium · 2 comments
Owner

"Primitives" as a term doesn't even actually show up in python - the closest is some mention to "basic types". Using the Python JSON docs as an example, the main types not currently supported that probably need to be added are tuples, and possibly int/float Enums. Both of these types present problems in that they'll need an equivalent of the class keys, for instance because both lists and tuples would otherwise get turned into an array by JSON, and lose their type.

The docs probably also need an update to include an actual list of supported types.

This will need a review of potential serialisation targets and their supported types, as this is the main purpose of Preserve. Will need to specifically look at conversion tables to make sure type information doesn't get lost and types don't get conflated.

"Primitives" as a term doesn't even actually show up in python - the closest is some mention to "basic types". Using the Python [JSON docs](https://docs.python.org/3/library/json.html#py-to-json-table) as an example, the main types not currently supported that probably need to be added are tuples, and possibly int/float Enums. Both of these types present problems in that they'll need an equivalent of the class keys, for instance because both lists and tuples would otherwise get turned into an array by JSON, and lose their type. The docs probably also need an update to include an actual list of supported types. This will need a review of potential serialisation targets and their supported types, as this is the main purpose of Preserve. Will need to specifically look at conversion tables to make sure type information doesn't get lost and types don't get conflated.
novirium added this to the v0.3 milestone 6 years ago
novirium added the [type] Bug [status] Review labels 6 years ago
Poster
Owner

Fundamentally, this not only needs to allow compatibility with other serialisers, but we need to make sure that any raw types (types that are passed directly through) will appear to be the same type when restoring - for instance in Python JSON, converting a tuple to JSON and then back again will coerce it into a list.

This should all be solved be adding a more flexible/generic configurable type system in Preserve.

Conversion table for python<->JSON (source) :

Python JSON
dict object
list array
str string
int number (int)
float number (real)
bool boolean

Conversion table for python<->TOML (source) :
(note that there's complications here with structure limits - namely that the root must be a table)

Python TOML
dict table
list array
str string
int integer
float float
bool boolean
Fundamentally, this not only needs to allow compatibility with other serialisers, but we need to make sure that any raw types (types that are passed directly through) will appear to be the same type when restoring - for instance in Python JSON, converting a tuple to JSON and then back again will coerce it into a list. This should all be solved be adding a more flexible/generic configurable type system in Preserve. Conversion table for python<->JSON ([source](https://docs.python.org/3/library/json.html#py-to-json-table)) : | Python | JSON | |--------|---------------| | dict | object | | list | array | | str | string | | int | number (int) | | float | number (real) | | bool | boolean | Conversion table for python<->TOML ([source](https://github.com/toml-lang/toml)) : (note that there's complications here with structure limits - namely that the root must be a table) | Python | TOML | |--------|---------| | dict | table | | list | array | | str | string | | int | integer | | float | float | | bool | boolean |
novirium closed this issue 6 years ago
Poster
Owner

Support for extra types moved to #12

Support for extra types moved to #12
novirium added [status] Done and removed [status] Review labels 6 years ago
Sign in to join this conversation.
Loading…
There is no content yet.