Skip to content

Add guidance for migration from Newtonsoft Attribute JsonObject Property Title #45862

Open
@jafin

Description

@jafin

Type of issue

Missing information

Description

For consideration

Newtonsoft.Json has the attribute

[JsonObject(Title = "title")]

Could you please provide documentation guidance (or note that it is not supported) on migrating from Newtonsoft.Json Attribute Property Title which is used for metadata schema generation.

My understanding is there is no parallel in System.Text.Json and the common option is just to rename the Class to the appropriate name.

Perhaps this is out of scope for Migration, given this is schema related, and maybe belongs closer to the OpenApi docs? unsure.

I can see that for OpenApi something like this can be done,

public class RenameSchemaTransformer : IDocumentTransformer
{
    public void Apply(OpenApiDocument document, OpenApiDocumentTransformerContext context)
    {
        if (document.Components.Schemas.TryGetValue("Address", out var schema))
        {
            document.Components.Schemas.Remove("Address");
            schema.Title = "address";
            document.Components.Schemas["address"] = schema;
        }
    }
}

Page URL

https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft

Content source URL

https://github.com/dotnet/docs/blob/main/docs/standard/serialization/system-text-json/migrate-from-newtonsoft.md

Document Version Independent Id

9c6a7135-eb75-21a9-1d27-0880459523ca

Platform Id

b4170058-145b-31e8-164f-9f71770c2ef2

Article author

@gewarren

Metadata

  • ID: 6b74d77c-33e1-d44c-18c6-bd0b612f74de
  • PlatformId: b4170058-145b-31e8-164f-9f71770c2ef2
  • Service: dotnet-fundamentals

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions