Skip to content

Type name info is not saved for F# unions with TypeNameHandling.All #972

@alfonsogarciacaro

Description

@alfonsogarciacaro

Hi there. When I try to serialise an F# union with settings TypeNameHandling=TypeNameHandling.All the type name info is not saved as with other types:

type Tree =
    | Leaf of int
    | Branch of Tree[]

let x = Leaf 5
let json = JsonConvert.SerializeObject(x,
                   JsonSerializerSettings(TypeNameHandling=TypeNameHandling.All))

// json = """{"Case":"Leaf","Fields":[5]}"""

With F# records and classes, the type name is correctly saved.

I'm using Newtonsoft.Json v9.0.1, please tell me if you need any other info.

Cheers!

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