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