Skip to content

Support for SumEncoding ObjectWithSingleField ? #43

Description

@Boscop

Is it possible to decode sum types in such a way that there is no tag field, no content field, to be able to parse sum types from json that are coming from a Rust server using encoding (with default serde settings*)?

Here is an example:

    print(PossibleValues::NumberValue(NumberValueRecord { a: 123, b: 42 }));
    print(PossibleValues::StringValue(StringValueRecord { a: 123, b: "asd".to_string() }));
    print(PossibleValues::Empty);
serialized = {"NumberValue":{"a":123,"b":42}}
serialized = {"StringValue":{"a":123,"b":"asd"}}
serialized = "Empty"

There is no tag or content field. I think I need ObjectWithSingleField but nullary constructors shouldn't be { "foo": [] } but "foo" (flattenContentsArray = true), is that combination possible in PureScript waterslide with automatic/generic deserialization?


*The API can't be changed anymore on the server-side because many apps and services already depend on it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions