Skip to content

[IMPROVEMENT] Add serialize to dict & deserialize from dict option #210

@Thijss

Description

@Thijss

Both me and @AllianderTim would like to add this feature.

The current serialize method on the Grid only serializes to json, but for some applications it can be useful to serialize to a variable (e.g. dict) instead. Shouldn't be too hard to implement because we are basically already working with dicts when writing to/reading from json.

Suggested method signature change:

class Grid:
    ...
    def serialize(path: Path, mode: Literal["json", "dict"] = "json", **kwargs):
        ...

We could then use @overload to specify different output types, depending on the mode.
We did a similar thing for FancyArray.__getitem__

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprovement on internal implementation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions