Can't get enum to convert to json properly using Json.NET

前端 未结 3 518
旧巷少年郎
旧巷少年郎 2020-12-06 04:52

I have an enum:

public enum Animal 
{ 
    Dog, 
    Cat, 
    BlackBear 
}

I need to send it to a third-party API. This API requires that

3条回答
  •  春和景丽
    2020-12-06 05:18

    I think your ConConvert() implementation is not correct. It should be:

    public override bool CanConvert(Type objectType)
    {
        return objectType == typeof(Animals);
    }
    

提交回复
热议问题