小编Gar*_*and的帖子

Json.NET StringEnumConverter无法按预期工作

I'm attempting to use Json.NET with the System.Net.Http.HttpClient to send an object with an enum property, however the enum is always serialized as an integer value rather than the string equivalent.

I've tried following the instructions here:

http://james.newtonking.com/archive/2013/05/08/json-net-5-0-release-5-defaultsettings-and-extension-data

By both adding an instance of StringEnumConverter to the JsonSerializerSettings and also tried to decorate the enum property with [JsonProperty(ItemConverterType = typeof(StringEnumConverter))] neither of which appear to be working in my example.

I'm using Json.NET version 5.0.8

Can anyone tell me what …

c# serialization json json.net

16
推荐指数
2
解决办法
2万
查看次数

标签 统计

c# ×1

json ×1

json.net ×1

serialization ×1