Skip to content

Enum Serialization with unwrapped field less tags creates invalid json #204

@marcpiechura

Description

@marcpiechura

After upgrading to Version 1.4.34 I can no longer serialize simple enums, it works with the previous version 1.3.13
This code:

type Enum =
    | Case1
    | Case2
    
type Record =
    { Field: Enum }


let options = 
    JsonFSharpOptions
        .Default()
        .WithUnionUnwrapFieldlessTags()
        .ToJsonSerializerOptions()

let json = JsonSerializer.Serialize({ Field = Enum.Case2 }, options)

Creates the following json

{"Field":"Case":"Case2"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions