Skip to content

Add a copy constructor to JsonSerializerOptions #30445

@pranavkm

Description

@pranavkm

(Edit by @jozkee: proposed API is in a comment at #30445 (comment))

MVC has a scenario where it needs to start with an existing options instance, modify a single property on a copy of it (the encoder) and perform serialization. In the absence of a copy constructor, we're at risk of missing out on newly added properties to the type.

Proposed API

namespace System.Text.Json
{
    public sealed partial class JsonSerializerOptions
    {
        public JsonSerializerOptions(JsonSerializerOptions source)
        {
            /* Copy all options from source to a new JsonSerializerOptions instance. */
        }
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions