Skip to content

Specifying a JSON enum string converter for a list property #99777

Answered by elgonzo
RenderMichael asked this question in General
Discussion options

You must be logged in to vote

Is there a more localized way of pulling this off, ideally on the Values property itself?

Depends on whether you want the desired behavior specifically only on the Values property, or specifically on the Numbers enum type regardless where it is being used in the object graph being (de)serialized.

If the behavior should be specific to the Values property (with other properties of the same enum type being unaffected), currently you would need to write a custom JsonConverter that then executes the StringEnumConverter on the collection items, similar to this implementation: #54189 (comment). This converter would then be applied to the Values property using the [JsonConverter] attribute. The…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@RenderMichael
Comment options

@RenderMichael
Comment options

@elgonzo
Comment options

Answer selected by RenderMichael
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants