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

Add support for JSON serialization with System.Text.Json #3

Open
thomaslevesque opened this issue Apr 10, 2024 · 0 comments
Open

Add support for JSON serialization with System.Text.Json #3

thomaslevesque opened this issue Apr 10, 2024 · 0 comments

Comments

@thomaslevesque
Copy link
Owner

thomaslevesque commented Apr 10, 2024

Using System.Text.Json, we can serialize Option<T> values to this:

{
  "Value": 42,
  "IsSome": true,
  "IsNone": false
}

but not deserialize it (it returns Option<T>.None).

The library should provide be a converter.

The JSON format could be something like this:

// Some
{
  "Value": 42
}

// None
{}

Note: serialization with Newtonsoft.Json works as expected (with the IsSome/IsNone properties)

@thomaslevesque thomaslevesque changed the title Add support for JSON serialization Add support for JSON serialization with System.Text.Json Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant