Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Workaround for providing support for EnumMemberAttribute #80838

Closed
snjosephms opened this issue Jan 19, 2023 · 2 comments
Closed

Workaround for providing support for EnumMemberAttribute #80838

snjosephms opened this issue Jan 19, 2023 · 2 comments

Comments

@snjosephms
Copy link

snjosephms commented Jan 19, 2023

We are migrating our code base from Newtonsoft to System.Text.Json.
Our data model uses the EnumMemberAttribute decorations https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.enummemberattribute?view=net-7.0.

Based on this post, I see that the support for this attribute is not provided in System.Text.Json out of the box : #74385 (comment)

The post mentions that we can implement custom converters to provide support for this - but its unclear to me how this can be done.
Can you please provide a sample implementation of such a custom converter?

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 19, 2023
@ghost
Copy link

ghost commented Jan 19, 2023

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

We are migrating our code base from Newtonsoft to System.Text.Json.
Our data model uses the EnumMemberAttribute decorations https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.enummemberattribute?view=net-7.0.

Based on this post, I see that the support for this attribute is not provided in System.Text.Json out of the box : #74385 (comment)

I there any workaround we can implement to provide this support?

Author: snjosephms
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@gregsdennis
Copy link
Contributor

That attribute isn't part of JSON serialization. That's for ASP.Net data contracts.

You can use EnumStringConverter<T> from my STJ utilities package Json.More.Net. More info at https://json-everything.net (click on "Additional Utilities" at the right of the header bar).

@dotnet dotnet locked and limited conversation to collaborators Jan 19, 2023
@eiriktsarpalis eiriktsarpalis converted this issue into discussion #80858 Jan 19, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jan 19, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants