← Back to archive
Programming Notes

Serializing Enum Array Types

Today I ran into a problem: how to serialize an array of Enum values. I first tried applying StringEnumConverter directly but could not solve it. After carefully reading the documentation, I found one should use ItemConverterType rather than applying JsonConvert directly — and with that it was solved.

[JsonProperty(PropertyName = "XXXX", ItemConverterType=typeof(StringEnumConverter))]

Written by Master Sanfu on February 13, 2019. Please credit the source if you share.

Translation Notice: This English version was translated with AI assistance. Specialized, historical, religious, or culturally sensitive terms may contain nuances, inaccuracies, or debatable wording. In case of ambiguity or discrepancy, the original Chinese text shall prevail.