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

JsonUnionEncoding.FSharpLuLike mismatch with fsharplu for single field union cases #32

Closed
johlrich opened this issue Dec 10, 2019 · 1 comment

Comments

@johlrich
Copy link
Contributor

There's a mismatch on the encoding for union cases with a single field when using JsonUnionEncoding.FSharpLuLike. In cases where field count = 1 FSharpLu will just serialize the object instead an array with the one object.

Example for type SingleFieldCase = Single of string

Current FSharpLuLike encoding: {"Single":["hi"]}

Actual FSharpLu encoding: { "Single": "hi" }

I was not sure what the best way to approach this would be wrt affecting other encoding options. Happy to help implement any acceptable changes as needed.

@Tarmil
Copy link
Owner

Tarmil commented Dec 11, 2019

Good catch! I think a good way to fix this would be to add an option to the JsonUnionEncoding enum, something like SuccintSingleFieldUnions = 0x10_00, that enables this behavior, and then FSharpLuLike would be 0x16_02.

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

No branches or pull requests

2 participants