Newtonsoft.Json DeserializeObject 反序列化 IdentityServer4.Models Cliecnt
错误:
Newtonsoft.Json.JsonSerializationException:
Unable to find a constructor to use for type System.Security.Claims.Claim. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'clients[0].Claims[0].Issuer', line 1, position 5373.
JsonConvert.DeserializeObject<T>(value); //会抛出Newtonsoft.Json.JsonSerializationException异常 //解决方案: JsonConvert.DeserializeObject<T>(value, new IdentityServer4.Stores.Serialization.ClaimConverter());
在IdentityServer4中,已经对System.Security.Claims.Claim做了处理。
使用IdentityServer4.Stores.Serialization.ClaimConverter()即可
在stackoverflow上有解决方案重载JsonConverter后写了ClaimConverter