cosullivan / Hypermedia

Hypermedia library for .NET
http://cainosullivan.com/Hypermedia
MIT License
47 stars 12 forks source link

Support `JsonPropertyNameAttribute` on Enum Deserialization #31

Open hughesjs opened 2 years ago

hughesjs commented 2 years ago

This one, again, might be a bit niche or might not be wanted. However, I often find I want to deserialise a string to an enum using a custom value through an attribute, like:

[EnumMember(Value = "Pld Frag Deb")]
PayloadFragmentationDebris,

As it stands, the simple Enum.Parse() used in EnumConverter doesn't (AFAICT) support this

hughesjs commented 2 years ago

33 was reverted. As was #34, so this is now reopened, as the solution proposed in this PR would require a .NET 6 upgrade.