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

详细请查看https://stackoverflow.com/questions/28155169/how-to-programmatically-choose-a-constructor-during-deserialization

Unable to find a constructor to use for type System.Security.Claims.Claim. A class should either have a default constructor的更多相关文章

  1. 构造函数语义学之Default Constructor构建操作

    一.Default Constructor的构建操作 首先大家要走出两个误区: 1).任何class如果没有定义default constructor,就会被合成一个来. 2).便以其合成出来的def ...

  2. C++对象模型(一):The Semantics of Constructors The Default Constructor (默认构造函数什么时候会被创建出来)

    本文是 Inside The C++ Object Model, Chapter 2的部分读书笔记. C++ Annotated Reference Manual中明确告诉我们: default co ...

  3. Constructor Overloading in Java with examples 构造方法重载 Default constructor 默认构造器 缺省构造器 创建对象 类实例化

    Providing Constructors for Your Classes (The Java™ Tutorials > Learning the Java Language > Cl ...

  4. 构造函数语义学——Default Constructor篇

    构造函数语义学--Default Constructor 篇 这一章原书主要分析了:编译器关于对象构造过程的干涉,即在对象构造这个过程中,编译器到底在背后做了什么 这一章的重点在于 default c ...

  5. The Semantics of Constructors: The Default Constructor (默认构造函数什么时候会被创建出来)

    本文是 Inside The C++ Object Model, Chapter 2的部分读书笔记. C++ Annotated Reference Manual中明确告诉我们: default co ...

  6. 错误:Implicit super constructor xx() is undefined for default constructor. Must define an explicit constructor

    错误:Implicit super constructor xx() is undefined for default constructor. Must define an explicit con ...

  7. Unable to load type System.Data.Entity.DynamicProxiesXXXXXrequired for deserialization.

    Memcache实例的Get方法时抛出了异常“Unable to load type System.Data.Entity.DynamicProxies.AdInfoItems_19CD09C8E46 ...

  8. C++编译器合成Default Constructor的4种情况

    笔记C++编译器为编译器需要合成Default Constructor的4种情况. 1,Class A内含Class B对象,Class A没有Default Constructor时会在编译时合成D ...

  9. Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead

    “Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(B ...

随机推荐

  1. BZOJ4836 [Lydsy1704月赛]二元运算 分治 多项式 FFT

    原文链接http://www.cnblogs.com/zhouzhendong/p/8830036.html 题目传送门 - BZOJ4836 题意 定义二元运算$opt$满足 $$x\ opt\ y ...

  2. vue 解决IE不能用的问题

    一般来说VUE本身是不支持IE的,但是可以用特殊的方法来解决,亲测可用第一步:下载插件 cnpm install --save babel-polyfill第二步:入口文件main.js引入( imp ...

  3. .net 本地日志的添加

    /// <summary> /// 写入日志到文本文件 /// </summary> /// <param name="userName">用户 ...

  4. asp+SqlServer2008开发【第一集:安装SqlServer2008以及登陆】

    参考:https://blog.csdn.net/i_likechard/article/details/75299983 1,安装sqlServer2008的具体步骤参考网上其他教程,自己根据注释引 ...

  5. Azure Database for MySQL 报 Please specify SSL options and retry.

    Exception has been thrown by the aspect of an invocation. ---> Authentication to host 'xxx.mysql. ...

  6. Leetcode中值得一做的题

    3.longest substring Given a string, find the length of the longest substring without repeating chara ...

  7. 修改input和textarea的placeholder的颜色,限制文本框字数输入

    <style type="text/css"> textarea{ width: 400px; height:400px; resize: none; } .limit ...

  8. iframe ios中h5页面 样式变大

    实际项目开发中,iframe在移动设备中使用问题还是很大的,说一说我的那些iframe坑 做过的这个后台管理框架,最开始的需求是PC,但随着业务需要,需要将项目兼容到ipad,后台的框架也是使用的开源 ...

  9. (18)0907_CSS选择器详解

    选择器的优先级(决定那个样式生效): important: > 内联样式 > id选择器> 类和伪类 > 元素选择器 > 通配选择器> 继承样式无优先级 最大    ...

  10. [LeetCode] Jewels and Stones 珠宝和石头

    You're given strings J representing the types of stones that are jewels, and S representing the ston ...