![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JSON
文章平均质量分 78
treeMountain
精通.NET开发,Web网页的开发
展开
-
JSON序列化与反序列化枚举
一、JSON序列化枚举1.这个示例使用了一个JsonConverter定制如何序列化JSON与反序列化枚举using System;using System.Collections.Generic;using System.Linq;using System.Text;using GongHuiNewtonsoft.Json;using GongHuiNewtonsof原创 2015-12-10 13:36:11 · 10201 阅读 · 0 评论 -
JSON继承JsonConverter序列化与反序列化重写类属性
1.首先自定义一个JSON类,继承JsonConverter,把类的属性重写到JSON中.using System;using System.Collections.Generic;using System.Linq;using System.Text;using GongHuiNewtonsoft.Json;using GongHuiNewtonsoft.Json.Lin原创 2015-12-11 15:36:42 · 7449 阅读 · 0 评论 -
JSON使用MaxDepth反序列化设置最大深度
1.当反序列化时,使用MaxDepth指定最大深度,本例最大深度实际是3,但指定为2.即抛出异常.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using GongHuiNewtonsoft.Json;using Go原创 2015-12-11 15:01:00 · 2991 阅读 · 0 评论 -
JSON使用Error反序列化忽略非法日期
1.JSON使用Error事件委托来忽略非法的日期,并且不抛出异常.注意:其中JSON字符串中有三个不是合法日期.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using GongHuiNewtonsoft.Json;原创 2015-12-11 14:49:00 · 1036 阅读 · 0 评论 -
JSON使用IContractResolver序列化实现属性名骆驼命名法
1.先创建一个Address对象,属性采用首字母大写using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Address { public string Pr原创 2015-12-11 14:14:02 · 5041 阅读 · 0 评论 -
JSON使用DateTimeZoneHandling序列化时时区与日期
1.先创建一个Flight类using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Flight { public string Destination { g原创 2015-12-11 11:30:56 · 4149 阅读 · 0 评论 -
JSON使用DateFormatHandling 序列化与反序列化日期设置
1. 序列化日期时的JSON日期格式化处理using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using GongHuiNewtonsoft.Json;namespace JSONDemo{ class P原创 2015-12-11 11:01:56 · 6904 阅读 · 0 评论 -
JSON使用PreserveReferencesHandling保存引用类型
1.先创建两个对象Directory和Fileusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Directory { public string Nam原创 2015-12-11 10:51:17 · 1341 阅读 · 0 评论 -
JSON使用ReferenceLoopHandling忽略其引用循环值
1.首先创建一个对象Employeeusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Employee { public string Name { ge原创 2015-12-11 10:11:10 · 4056 阅读 · 0 评论 -
JSON使用MissingMemberHandling 反序列化对象中不匹配成员的异常
1.创建一个Account对象,并添加成员.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Account { public string Email原创 2015-12-11 09:39:30 · 2357 阅读 · 0 评论 -
JSON使用DefaultValueHandling与NullValueHandling 不序列化属性的默认值与null
1.首先创建一个Person对象,对属性不赋值.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Person { private decimal? _s原创 2015-12-11 09:17:56 · 11791 阅读 · 2 评论 -
JSON使用ObjectCreationHandling 反序列化替换不重复的值
1.首先创建一个实例对象City,并声明构造函数.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class City { public string Countr原创 2015-12-11 08:53:09 · 1228 阅读 · 0 评论 -
JSON使用ConstructorHanding反序列化非公共构造函数
1.首先创建一个类,含有私有的构造函数.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Website { public string Url { ge原创 2015-12-11 08:31:22 · 1225 阅读 · 0 评论 -
JSON在已有的对象上填充新的JSON
1.首先声明一个对象Accountusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Account { public string Email { get原创 2015-12-10 17:06:16 · 1616 阅读 · 0 评论 -
JSON序列化与反序列化匿名类型
一、序列化匿名类型1.序列化一个var类型using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using GongHuiNewtonsoft.Json;namespace JSONDemo{ class原创 2015-12-10 16:46:35 · 10593 阅读 · 1 评论 -
JSON序列化与反序列化对象中条件化的属性
一、序列化中对象的部分属性1.首先创建一个Employeeusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Employee { public str原创 2015-12-10 16:29:11 · 1038 阅读 · 0 评论 -
JSON序列化与反序列化没有任何格式或空格缩进的对象
一、序列化没有任何格式或空格缩进的对象1.首先创建一个Account对象using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Account { publ原创 2015-12-10 15:25:07 · 3631 阅读 · 0 评论 -
JSON序列化与反序列化JavaScript
一、JSON序列化JavaScript1.首先创建一个JavaScriptSettings对象using System;using System.Collections.Generic;using System.Linq;using System.Text;using GongHuiNewtonsoft.Json.Linq;namespace JSONDemo{原创 2015-12-10 14:57:40 · 532 阅读 · 0 评论 -
JSON继承DefaultContractResolver根据首字母序列化与反序列对象成员
1.先创建一个DynamicContractResolver对象,继承DefaultContractResolver,然后重写CreateProperties方法.using System;using System.Collections.Generic;using System.Linq;using System.Text;using GongHuiNewtonsoft.Js原创 2015-12-11 15:58:03 · 2527 阅读 · 0 评论 -
JSON继承SerializationBinder序列化与反序列化包含对象名
1.创建一个KnownTypesBinder继承SerializationBinder的对象,并把对象名添加到成员变量中.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.Serialization;namespac原创 2015-12-11 16:29:12 · 1482 阅读 · 0 评论 -
JSON序列化与反序列化到文件
一、序列化成一个文件1.JSON序列化成一个文件,此文件到记事本可以打开。首先先创建一个Movie对象.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Movie {原创 2015-12-10 11:35:19 · 1433 阅读 · 1 评论 -
JSON序列化与反序列化一个字典
一、序列化一个字典1.JSON序列化一个persons的Dictionary.using System;using System.Collections.Generic;using System.Linq;using System.Text;using Newtonsoft.Json;namespace JSONDemo{ class Program原创 2015-12-10 11:01:51 · 507 阅读 · 0 评论 -
JSON序列化与反序列化对象
一.把一个对象序列化JSON.1.对象Accountusing System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Account { public string原创 2015-12-10 10:19:53 · 553 阅读 · 0 评论 -
JSON序列化与反序列化一个集合
一、JSON序列化一个集合1.序列化集合filmsusing System;using System.Collections.Generic;using System.Linq;using System.Text;using Newtonsoft.Json;namespace JSONDemo{ class Program {原创 2015-12-10 10:45:07 · 4367 阅读 · 0 评论 -
JSON序列化与反序列化DataSet
一、序列化一个DataSet1.首先创建一个DataSet对象.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;namespace JSONDemo{ public class DataSetClass原创 2015-12-10 14:24:30 · 2920 阅读 · 0 评论 -
JSON写、读文件
二、JSON中使用JsonTextReader,JObject,JToken读file1.先使用C#中的File.OpenText()方法,然后使用JSON的相关类方法using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;us原创 2015-12-15 13:30:03 · 2143 阅读 · 1 评论 -
JSON中JObject和JArray的修改
1.先添加一个json字符串,把json字符串加载到JObject中,然后转换成JObject.根据索引修改对象的属性值,移除属性,添加属性using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Web;原创 2015-12-15 08:59:15 · 15771 阅读 · 1 评论 -
JSON使用Linq序列化与反序列化.NET类型
1.先创建一个json字符串,用转换成JArray数组,然后创建一个Post对象.把这个对象添加到List列表中.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Web;using GongHu原创 2015-12-15 08:20:39 · 1382 阅读 · 0 评论 -
JSON中使用JArray.Parse
一.JArray.Parse(String)的使用1.案例如下:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using GongHuiNewtonsoft.Json.Linq;namespace JSONDe原创 2015-12-14 16:57:24 · 7064 阅读 · 1 评论 -
JSON序列化与反序列化扩展数据
1.先创建一个Invoice对象,然后定义一个decimal类型的属性.using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace JSONDemo{ public class Invoice { public原创 2015-12-14 11:03:33 · 580 阅读 · 0 评论 -
JSON使用DataContract和DataMember
1.先创建一个File对象,然后引用using System.Runtime.Serialization.再分别在类和成员上添加DataContract和DataMember.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime原创 2015-12-14 10:12:45 · 3681 阅读 · 0 评论 -
JSON使用OnSerializing,OnSerialized,OnDeserializing,OnDeserialized
1.创建一个SerializationEvent对象,引用System.Runtime.Serialization命名空间.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Runtime.Serialization;namespa原创 2015-12-14 09:29:54 · 716 阅读 · 0 评论 -
JSON使用JsonIgnoreAttribute,ErrorHandlingAttribute,DefaultValueAttribute
一、使用JsonIgnoreAttribute忽略其属性序列化1.创建一个Movie对象,并在其属性上添加JsonIgnore.using System;using System.Collections.Generic;using System.Linq;using System.Text;using GongHuiNewtonsoft.Json;namespace原创 2015-12-12 12:02:15 · 1900 阅读 · 0 评论 -
JSON使用JsonPropertyAttribute
一、JSON使用JsonPropertyAttribute重命名属性名1.先创建一个Movie对象,然后在其属性上添加JsonProperty,并指定重命名的名称。注意:属性Name和Director已指定。using System;using System.Collections.Generic;using System.Linq;using System.Text;us原创 2015-12-12 08:55:05 · 14377 阅读 · 3 评论 -
JSON使用JsonConstructorAttribute,JsonConverterAttribute,JsonObjectAttribute
1.创建一个User对象.并添加JsonConstructor.using System;using System.Collections.Generic;using System.Linq;using System.Text;using GongHuiNewtonsoft.Json;namespace JSONDemo{ public class Use原创 2015-12-11 16:43:31 · 4160 阅读 · 0 评论 -
MVC中iCheck,src相关问题
1、iCheck动态选中$("#checkId").原创 2017-12-29 12:49:39 · 366 阅读 · 0 评论