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

"read too much or not enough" when parsing list of DU-elements #33

Closed
drhumlen opened this issue Dec 16, 2019 · 0 comments
Closed

"read too much or not enough" when parsing list of DU-elements #33

drhumlen opened this issue Dec 16, 2019 · 0 comments
Labels
bug Something isn't working released: v0.8

Comments

@drhumlen
Copy link

System.Text.Json.JsonException: The converter 'System.Text.Json.Serialization.JsonUnionConverter`1[KT.Takst.Domain+ForholdVedBygg]' read too much or not enough. Path: $[1] | LineNumber: 0 | BytePositionInLine: 24.

using these options:

    let serializerOptions =
        let rules =
            JsonUnionEncoding.InternalTag ||| JsonUnionEncoding.EraseSingleCaseUnions ||| JsonUnionEncoding.SuccintOption
            ||| JsonUnionEncoding.BareFieldlessTags

        let serializerOptions =
            JsonSerializerOptions(PropertyNamingPolicy = JsonNamingPolicy.CamelCase, DictionaryKeyPolicy = JsonNamingPolicy.CamelCase)
        serializerOptions.Converters.Add(JsonFSharpConverter(rules))

Given example:

type Color = Red | Blue | Green

JsonSerializer.Deserialize<Color list>("""[ "Red", "Blue"] """, serializerOptions)
@Tarmil Tarmil added the bug Something isn't working label Dec 16, 2019
@Tarmil Tarmil closed this as completed in 25660d9 Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released: v0.8
Projects
None yet
Development

No branches or pull requests

2 participants