JSON: Support [JsonStringEnumConverter]
See original GitHub issueSystem.Text.Json has [JsonStringEnumConverter]
, which maps CLR enums to strings in the JSON document.
I’m not sure if we plan to support arbitrary EF value converters for JSON properties (we should probably open an issue for that). If we do, then we could set up the appropriate enum/string converter when we see this attribute.
Originally requested for Npgsql by @sergeyshaykhullin in https://github.com/npgsql/efcore.pg/issues/2325
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
JsonStringEnumConverter Class (System.Text.Json. ...
JsonStringEnumConverter (). Initializes an instance of the JsonStringEnumConverter class with the default naming policy that allows integer values.
Read more >c# - Does JsonStringEnumConverter (System.Text.Json) ...
Unfortunately, there is currently no support "out-of-the-box" in System.Text.Json to convert nullable enums. However, there is a solution by ...
Read more >Data binding and serialization issue with System.Text.Json ...
In Microsoft's documentation I see that using the JsonStringEnumConverter serializes enums, including nullable enums, so if there is an issue ...
Read more >How to Serialize Enum to a String in C# - Code Maze
In C#, JSON serialization very often needs to deal with enum objects. ... as JsonStringEnumConverter and StringEnumConverter respectively.
Read more >Serializing enums as strings using System.Text.Json library ...
The new library has got support for all the new features that got ... { Converters ={ new JsonStringEnumConverter() } }; JsonSerializer.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@roji I think that enum property with
.HasConversion<string>()
should also translate toCAST(p.barcode->>'type' AS text)
Notes from triage:
EnumToStringConverter
by default.